'header 301 Moved Permanently' redirects twice?
Posted: Wed Jul 05, 2006 5:35 am
Situation:
I have multiple domains in Apache which are aliasses for the 'main-domain'
I want to make sure that Google only indexes this maindomain.
I do not want use mod_rewrite or something for this.
I add the folowing to index.php:
But when i do a wget:
It does get redirected to the main-domain, but then he tries to redirect it again. It looks like it doesn't follow the if-statement and tries to send the header again.
Is this normal behaviour? Or is there a solution for this?
I have multiple domains in Apache which are aliasses for the 'main-domain'
I want to make sure that Google only indexes this maindomain.
I do not want use mod_rewrite or something for this.
I add the folowing to index.php:
Code: Select all
<?
if (substr($HTTP_HOST, 4)!="maindomain.com")
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.maindomain.com/index.php");
exit;
}
?>Code: Select all
C:\>wget www.aliasdomain.com
--11:37:17-- http://www.aliasdomain.com:80/
=> `index.html.1'
Connecting to www.aliasdomain.com:80... connected!
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.maindomain.com/index.php [following]
--11:37:17-- http://www.maindomain.com:80/index.php
=> `index.php.1'
Connecting to www.maindomain.com:80... connected!
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.maindomain.com/index.php [following]
http://www.maindomain.com/index.php: Redirection to itself.Is this normal behaviour? Or is there a solution for this?