我在IIS上运行一个小型的ASP.NET4网站。我最近把域名从'olddomain.com‘改成了'newdomain.com’。更改是通过Plesk完成的。进行更改后,我在plesk中添加了'olddomain.com‘作为域名别名,这样流量仍然会路由到旧域名上的网站。
到目前为止,这还不错。该网站解析旧的和新的URL。
然而,现在我想在任何地方设置301重定向,这样任何对olddomain.com的请求都会被转发到newdomain.com。网站页面都没有改变--这只是一个简单的域名改变。
我已经将此代码添加到web.config文件中:
<rewrite>
<rules>
<rule name="Redirect all to different domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^olddomain.com$" />
</conditions>
<action type="Redirect" url="http://www.newdomain.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite> 但它似乎没有任何影响;当我在浏览器中加载olddomain.com时,它只会加载网站,而不会重定向到newdomain.com。
有谁能建议我在这里做错了什么,以及如何让301正常工作?
谢谢
发布于 2013-07-23 18:25:21
这是可行的:
<rule name="redirectDomain" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" url="http://www.newdomain.com/{R:1}" redirectType="Permanent" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www.)?olddomain\.com$" />
</conditions>
</rule>发布于 2013-07-02 20:55:11
您也可以从IIS设置301永久重定向。
如果在旧服务器上启用了http重定向,那么您必须将新的web配置与内容-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://mynewsite.com/" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>如果有帮助,请告诉我。
https://stackoverflow.com/questions/17425953
复制相似问题