ASP.NET httpRedirect:重定向所有页面,除了一个

前端之家收集整理的这篇文章主要介绍了ASP.NET httpRedirect:重定向所有页面,除了一个前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用这个代码在web.config在我的网站的一个文件夹中的所有页面重定向到根,因为我想永久关闭这一节。
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <configuration>
  3. <location>
  4. <system.webServer>
  5. <httpRedirect enabled="true" destination="http://www.example.com/" httpResponseStatus="Permanent" />
  6. </system.webServer>
  7. </location>
  8. </configuration>

但是我需要对这个规则做一个例外:我不希望我的页面“default.aspx”被重定向。我怎样才能做到这一点?

解决方法

您可以按以下方式添加通配符,仅重定向某些文件
  1. <configuration>
  2. <system.webServer>
  3. <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
  4. <add wildcard="*.PHP" destination="/default.htm" />
  5. </httpRedirect>
  6. </system.webServer>
  7. </configuration>

但是我不知道你是否可以否定这一点,所以它忽略了某个文件

猜你在找的asp.Net相关文章