Jump to content

very simple but I am being very dumb


saltedm8

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);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.