How can I forward ALL pages to the same exact page on a different domain using .htaccess?

穿精又带淫゛_ 提交于 2019-12-08 09:33:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!