开发者

rewrite 301 replace domain name with a new domain name

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

ive www.dom开发者_Python百科ain1.com/page1/ want to be redirect to domain2.com/page1/

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


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]


When redirecting from one domain name to another, you should also take the www prefix into account. This Rewrite rule will match the old domain name with or without the www prefix.

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$    [NC]
RewriteRule ^(.*)$       http://newdomain.com/$1   [R=301]

or if you prefer to keep the www prefix, substitute this RewriteRule:

RewriteRule ^(.*)$       http://www.newdomain.com/$1   [R=301]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜