重写301使用新的域名更换域名域名、重写

2023-09-02 01:11:31 作者:丢了幸福的猪

男人 我需要mod-rewrite301一些帮助,我的旧网址重定向到新的地址, 这里是我的方案

guys I need some help on mod rewrite 301 , to redirect my old website address to the new address , here is my scenario

IVE www.domain1.com/page1/ 想重定向到domain2.com/page1 /

ive www.domain1.com/page1/ want to be redirect to domain2.com/page1/

香港专业教育学院,以取代所有的请求到达域1与域2和后.COM保持页面 所以watever是后.COM应该是相同只需更换域1与域2。 任何人都可以帮我这个 问候

ive to replace all request goes to domain1 with domain2 and keep the page after .com so watever was after .com should be the same just replace domain1 with domain2 . anyone can help me with this Regards

推荐答案

您可能希望确保UseCanonicalName关闭,以免阿帕奇更换主机名与该网站的服务器名称。

You may want to make sure UseCanonicalName is off, lest apache replace hostnames with the site's ServerName.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain1.com$    [NC]
RewriteRule ^(.*)$       http://domain2.com$1   [R=301]