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
www.randomdirectory.sitename.com
and is now located at sitename.com (with no www. at the beginning) is there a way to 301 redirect this so Google knows that it has moved?
I've done typical 301 redirects of files and directories.
However this new site was initially located at
www.randomdirectory.sitename.com
and is now located at sitename.com (with no www. at the beginning) is there a way to 301 redirect this so Google knows that it has moved?
« Older Sugar, spice, and everything nice, but mostly... | What are some tips for aspiring beanplating... Newer »
This thread is closed to new comments.
This will get anything that's NOT starting with sitename.com and 301 redirect it with the full path intact to sitename.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^sitename\.com$ [NC]
RewriteRule ^(.*)$ http://sitename.com/$1 [R=301,L]
if you just want www removed, but have other domains left intact (like test.sitename.com, beta.sitename.com, etc) then change the RewriteCond to:
RewriteCond %{HTTP_HOST} ^www\.sitename\.com$ [NC]
posted by TravellingDen at 3:26 PM on November 22, 2010