NLe*_*may 22 asp.net web-config http-redirect
我在我网站的一个文件夹中的web.config中使用此代码将所有页面重定向到根目录,因为我想永久关闭此部分.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location>
<system.webServer>
<httpRedirect enabled="true" destination="http://www.example.com/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但我需要对此规则进行例外处理:我不希望我的页面"default.aspx"被重定向.我怎样才能做到这一点?
CZF*_*Fox 39
将Default.aspx <location>与禁用的httpRedirect一样.如果你放在<location>之前或之后没关系<system.webServer>.
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://www.example.com/" exactDestination="true" httpResponseStatus="Permanent" />
</system.webServer>
<location path="Default.aspx">
<system.webServer>
<httpRedirect enabled="false" />
</system.webServer>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
sha*_*wty 12
您可以通过以下方式添加通配符,以仅重定向某些文件:
<configuration>
<system.webServer>
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*.php" destination="/default.htm" />
</httpRedirect>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是我不确定你是否可以否定它,所以它忽略了某个文件.
| 归档时间: |
|
| 查看次数: |
44469 次 |
| 最近记录: |