Tag Archives: .htaccess redirect

How to redirect all urls to another url through .htaccess?

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 new domain http://www.xyz.com/blog. So you have to include the following rules into old blog site’s .htaccess file; means when some one access 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]
read more