2015-07-29

Using .htaccess to redirect from one domain to another

If you want to redirect your www.from.com  to  www.to.com

[.htaccess]
in your root directory(or sub-directory, according to ur needs), create an .htaccess file, and input content below.


RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.from.com$ [NC]
RewriteRule ^(.*)$ http://www.to.com/$1 [R=301,L]


[例子]
RewriteEngine On
# 從  from.com  轉到 www.to.info
RewriteCond %{HTTP_HOST} ^from\.com$ [NC]
RewriteRule ^(.*)$ http://www.to.info/$1 [L,R=301]
# 從  www.from.com  轉到 www.to.info
RewriteCond %{HTTP_HOST} ^www\.from\.com$ [NC]
RewriteRule ^(.*)$ http://www.to.info/$1 [R=301,L]



[try]

go to browser URL input http://www.from.com/account/login and then you will be redirected to http://www.to.com/account/login

URI is corrected be mapped.





沒有留言:

張貼留言