Webmaster Hack – How to Redirect your Multiple Pages using .Htaccess wildcard!

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:

RewriteEngine On
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.

Leave a Reply

Your email address will not be published.

Other interesting stuff at Zedomax.com: , , ,
Check out more interesting categories: Blog, DIY, Featured Hacks, Featured Web, Hack, HOWTO, Projects, Web.

Related News and Resources