How to do lots of 301 Redirect (Tomcat?

301 Redirect Headache

  • 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?

  • Answer:

    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 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]

matimer at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.