Forum Moderators: phranque

Message Too Old, No Replies

Dangerous 301 code?

         

keyplyr

10:53 am on Feb 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is effective in forwarding some badly spelled incoming links, some of which managed to get into ATW SERPs (they're not responding to email requests to delete.)

RewriteCond %{HTTP_HOST} ^.+www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Could this be confused with duplicate content? Thanks.

jdMorgan

3:18 pm on Feb 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



keyplyr,

Given a properly-functioning search engine spider, a 301 is not dangerous. A 301 is telling the spider that the requested resource has been moved permanently. One interpretation of that would be, "We're redirecting this URL because otherwise you, Mr. spider, would see duplicate content.

Since you apparaently have wild-card DNS enabled, which will resolve any subdomain to your main domain's pages, it would be far more dangerous to not redirect spurious or non-unique subdomains.

To fix this problem, you can use either the code you posted, or the "classic" version, which redirects any non-standard domain request to the main domain:


RewriteCond %{HTTP_HOST} !^www\.maindomain\.com
RewriteRule (.*) http://www.maindomain.com/$1 [R=301,L]

Jim

keyplyr

7:15 pm on Feb 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Jim

I always feel better bouncing my schemes offa you guys ;)

keyplyr

7:22 pm on Feb 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Now, I have another line which resolves mistakes in the number of www's typed. So by combining these two, am I being redundant? Thanks

RewriteCond %{HTTP_HOST} ^w [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} ^.+www\.example\.com [NC]
RewriteRule (.*) http://www.example/$1 [R=301,L]

<added>

Testing proves otherwise. I need to keep them seperate:


RewriteCond %{HTTP_HOST} ^.+www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^w [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]