Jump to content

Recommended Posts

would anyone please help me work out why this is not working and even if I use the || operators it still wont work 

 

<?php 

$referer = $_SERVER['HTTP_REFERER'];

if ($referer != 'http://digitalpixels.co.uk/portfolio' ) 
header('Location: http://digitalpixels.co.uk/404/') ;

if ($referer != 'http://digitalpixels.co.uk/windscreen-repair-company' ) 
header('Location: http://digitalpixels.co.uk/404/')


?> 

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/227728-very-simple-but-i-am-being-very-dumb/
Share on other sites

You need to add an exit after header like so:

 

$referer = $_SERVER['HTTP_REFERER'];

if ($referer != 'http://digitalpixels.co.uk/portfolio') {
    header('Location: http://digitalpixels.co.uk/404/') ;
    exit(0);
}

if ($referer != 'http://digitalpixels.co.uk/windscreen-repair-company') {
    header('Location: http://digitalpixels.co.uk/404/');
    exit(0);
}

It's a little difficult to tell what the issue is, but it seems you would want to merge the two ifs. If it's not 'portfolio' and not 'windscreen-repair-company', redirect to 404:

 

<?php
$referer = $_SERVER['HTTP_REFERER'];
if ($referer != 'http://digitalpixels.co.uk/portfolio' && $referer != 'http://digitalpixels.co.uk/windscreen-repair-company') {
    header('Location: http://digitalpixels.co.uk/404/') ;
    exit(0);
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.