加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 00:41:55 所属栏目:asp.Net 来源:网络整理
导读:我使用这个代码在web.config在我的网站的一个文件夹中的所有页面重定向到根,因为我想永久关闭这一节。 ?xml version="1.0" encoding="utf-8"?configuration location system.webServer httpRedirect enabled="true" destination="http://www.example.com/"
我使用这个代码在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>

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

解决方法

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读