As I understand it, $_SERVER['HTTP_HOST'] should give me the web address of the calling website. But when I do this:
<?php
$wwwcheck = $_SERVER['HTTP_HOST'];
if(preg_match("/website1.com|website2.co.uk/", $wwwcheck))
{
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http:// www.newwebsite.com/" );
}
elseif(preg_match("/example.com|example2.org/", $wwwcheck))
{
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http:// www.otherwebsite.co.uk/" );
}
else
{
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http:// www.3rdsite.org/" );
}
?>
whilst website1.com, website2.co.uk etc. redirect just fine, things like website1.com/folder or example2.org/file.html result in an error.
Anyone know why that might be?