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 – and 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
http://www.domain.com/new/page.php, Becomes; http://www.domain.com/page.php
http://www.domain.com/new/test/another/, Becomes; http://www.domain.com/test/another/
My next redirect blog post will be how to move an entire new site to a new domain, complete with wild-cards!