Forum Moderators: phranque

Message Too Old, No Replies

My 301 redirect doesn't work anymore ...

Was working some time ago. Nothing changed. Why?

         

GreenLeaf

6:52 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Hi all!

Recently i did a search site:www.mydomain.com and noticed that Google contains a whole bunch of urls with the domain that i'm redirecting with 301 to the main url.
When i created my .htaccess file for redirected domain i tested it in WebmasterWorld server header checker and all was Ok, i saw that 301 redirect.
Now WebmasterWorld server header checker tells that it see 200 Ok.
But i didn't changed anything!
My .htaccess :

RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.maindomain\.com [NC]
RewriteRule ^(.*) [maindomain.com...] [R=301,L]

It was working some time ago and doesn't work now.
What could be the reason?

Thanks in advance.

jdMorgan

7:16 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's nothing wrong with your code. You should contact your host and see what they have changed.

(Note that posting on this board removes a required space between "}" and "!" in the RewriteCond. This will cause a 500-Server Error if not corrected before use.)

[added]
I would suggest adding another RewriteCond ahead of your first one:


RewriteCond %{HTTP_HOST} .

This will prevent an infinite redirection loop should a true HTTP/1.0 client try to access your site. True HTTP/1.0 clients will not provide a Hostname header, and this would cause your rule to loop.
[/added]

Jim

GreenLeaf

7:44 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Thanks a lot, Jim!

One more question: do i need to have a robots.txt for redirected domain with the following content:

User-agent: *
Disallow: /

jdMorgan

11:54 pm on Nov 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No. If you do that, then robots will never try to fetch the pages from the 'alternate' domain, and so will never 'see' your redirect to the new domain.

Jim

GreenLeaf

5:22 pm on Nov 29, 2004 (gmt 0)

10+ Year Member



Thanks again, Jim, for your help!