BlogArchive301 Redirects – Move a site down a directory wildcard

301 Redirects – Move a site down a directory wildcard

301 redirects, a few things you should know

When we build a new website for a customer we sometimes build it on their live domain, but in a sub-folder like /dev /new – then when the time comes to make the site live there is sometimes the need to put a redirect in place in case Google has cached the development URLs.

Now whenever something bakes my noodle and no one in the office can help, I turn to Google but from time to time the big G lets me down too.

When that happens I turn to our developer Olly, to see if he has an idea..

Once again, he saved the day.

If you would like a wildcard redirect to move everything down a directory, then use the following line in your HTACCESS file;

RewriteRule ^new/(.*)$ /$1 [R=301,NC,L]

Replace new with the directory (or directories) you wish to remove from the cached URL’s.

Example:

http://www.domain.com/new/page.php, Becomes; http://www.domain.com/page.php

Or

http://www.domain.com/new/test/another/,  Becomes; http://www.domain.com/test/another/

My next 301 redirects blog post will be how to move an entire new site to a new domain, complete with wild-cards.

For more information regarding 301 redirects you can visit the Google Webmaster Support blog.

One thought on “301 Redirects – Move a site down a directory wildcard

Leave a Reply

Your email address will not be published. Required fields are marked *