One of my friends Josh over at Unconventional Marketing asked me how to redirect his old website to a new URL using .htaccess file.
Well, I haven’t messed around much with .htaccess file since I’ve stopped using Apache web servers but I did figure it out in about 10 minutes.
For example, if you want to redirect all pages under your http://oldsite.com/thisdirectory to http://newsite.com/thisdirectory then you can edit your .htaccess file (of oldsite.com) and adding the following:
redirectMatch 301 ^/thisdirectory(.*)$ http://newsite.com/thisdirectory$1
redirectMatch permanent ^/thisdirectory(.*)$ http://newsite.com/thisdirectory$1
This will effectively move each webpage under /thisdirectory to the the URL.
For example, this will redirect http://oldsite.com/thisdirectory/myfile.php to http://newsite.com/thisdirectory/myfile.php.
That way, you don’t need a redirect for each file, that would be a hassle for those of you with multiple web pages to move.