How to Redirect all URLs to Another URL Through .htaccess?

November 16, 2011 / cPanel

If you wish to redirect all the URLs from one site to another site’s URL, then go through the following rewrite rules in .htaccess files.

For Example …

You want to redirect your old blog site http://www.abc.com/blog to a new domain http://www.xyz.com/blog. So you have to include the following rules into the old blog site’s .htaccess file; which means when someone accesses the URL http://www.abc.com/blog/anything it will be redirected to http://www.xyz.com/anything.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\com\blog
RewriteRule ^(.*)$ http://www.abc.com/blog$1 [R=301,L]
RewriteRule ^$ http://www.xyz.com/ [L]
RewriteRule (.*) http://www.xyz.com/$1 [L]
</IfModule>

Note: Replace “www.abc.com/blog” equal to your old blog URL and also replace “www.xyz.com” equal to your new blog URL.

1 Comment

  1. I do totally share your opinion and I am glad that there are still people who think so. Let’s fight for it,because “Opinions cannot survive if one has no chance to fight for them.”

Leave a Reply

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