问题
How can I do a 301 redirect of ALL pages on a site to the same exact page on a different domain using .htaccess?
For example, forward:
www.currentdomain.com/page1.php
www.currentdomain.com/page2.php?p=1&t=75
www.currentdomain.com/archived/old/page100.php
To:
www.newdomain.com/page1.php
www.newdomain.com/page2.php?p=1&t=75
www.newdomain.com/archived/old/page100.php
回答1:
According to about.com's article, the following should redirect ALL traffic to a new domain:
RewriteEngine ON
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
回答2:
In the root of your website add in the .htaccess file:
Redirect 301 /page1.php www.newdomain.com/page1.php
Without mod_rewrite you can't transfer the parameters. Further you have to have 1 line per existing file with .htaccess that you want to forward.
I know you didn't ask, but you can do the entire domain including the parameters with 1 line using mod_rewrite.
来源:https://stackoverflow.com/questions/8168065/how-can-i-forward-all-pages-to-the-same-exact-page-on-a-different-domain-using