web.config:redirect 301不';我不能正常工作
我想对一个站点(还有图像、文档和其他文件)上的所有请求进行301重定向,重定向到另一个站点的主页 我尝试将web.config放在网站的根目录下,并插入以下代码:web.config:redirect 301不';我不能正常工作,redirect,web-config,http-status-code-301,Redirect,Web Config,Http Status Code 301,我想对一个站点(还有图像、文档和其他文件)上的所有请求进行301重定向,重定向到另一个站点的主页 我尝试将web.config放在网站的根目录下,并插入以下代码: <?xml version="1.0" encoding="utf-8"?> <configuration> <location> <system.webServer> <httpErrors existingResponse="PassThrough"
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
<httpRedirect enabled="true" destination="http://www.newsite.com/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
但在web.config上使用此代码时,问题是如果我:
浏览器将我重定向到:
但是我需要所有的重定向都在主页上
如何操作?您需要设置
exactDestination=“true”
以使目的地成为绝对目的地:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
<httpRedirect exactDestination="true" enabled="true" destination="http://www.newsite.com/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
见: