将domain.com/contact.html重定向到newdomain.com/contact.html

时间:2012-11-05 14:59:30

标签: .htaccess redirect

我想将一个html页面重定向到另一个域,这个联系表单就像这个www.abc.com/contact.html一样,但没有 www ,就像xyz.com/contact.html一样。

我有两个具有相同数据的域名(只是域名不同)。 xyz.com上的表单工作得很好,但是abc.com上的表单不起作用,即使两个域上的代码是100%相同。

1 个答案:

答案 0 :(得分:0)

只需在.htaccess文件中添加以下行。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www?.abc.com [NC]
RewriteRule ^contact\.html$ http://xyz.com%{REQUEST_URI} [R=301,L]

修改

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.abc.com [NC]
RewriteRule ^contact\.html$ http://xyz.com%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^abc.com [NC]
RewriteRule ^contact\.html$ http://xyz.com%{REQUEST_URI} [R=301,L]