从所有旧域url重定向到新域url时出现一些错误

时间:2016-09-16 19:41:33

标签: .htaccess url redirect dns url-redirection

当重定向到旧网站网址到新网站网址时,结果如下: www.newdomain.comabout.html /

但我想这样: www.newdomain.com/about.htm

我的旧网站网址是这样的:
www.olddomain.com/about.html
www.olddomain.com/contact.html
www.olddomain.com/location.html

我的新网站网址是这样的:
www.newdomain.com/about.htm
www.newdomain.com/contact.htm
www.newdomain.com/location.htm

您可以注意到,我已在新域中将文件扩展名从html更改为htm。

我在编辑旧域.htaccess文件时试过这个:
重定向301 /about.html http://www.newdomain.com/about.htm

并尝试了这个(插入旧域名网址):

<meta http-equiv="refresh" content="0; url=http://www.newdomain.com/about.htm">

两者都不起作用。请帮忙。

1 个答案:

答案 0 :(得分:0)

尝试在olddomain的.htaccess文件中使用以下代码:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$ [NC]
RewriteRule ^(.+\.htm)l$ http://www.newdomain.com/$1 [R=301,L]
相关问题