301 Redirect Headache
November 22, 2010 3:16 PM   Subscribe

A weird 301 redirect request for a website.

I've done typical 301 redirects of files and directories.

However this new site was initially located at

and is now located at (with no www. at the beginning) is there a way to 301 redirect this so Google knows that it has moved?
posted by matimer to Technology (1 answer total)
This should do it - in the virtual host config (or adapted for .htaccess - I forget what if anything needs to change in that case, sorry)

This will get anything that's NOT starting with and 301 redirect it with the full path intact to

RewriteEngine On
RewriteCond %{HTTP_HOST} !^sitename\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

if you just want www removed, but have other domains left intact (like,, etc) then change the RewriteCond to:
RewriteCond %{HTTP_HOST} ^www\.sitename\.com$ [NC]
posted by TravellingDen at 3:26 PM on November 22, 2010

« Older How bad is it, really, to have...   |  What are some tips for writing... Newer »
This thread is closed to new comments.