【问题标题】:Using URLrewrite on static subdirectories在静态子目录上使用 URLrewrite
【发布时间】:2011-05-23 21:07:30
【问题描述】:

我想将随机子目录重定向到我使用 IIS 的 URLrewrite 制作的处理程序脚本。我编写的这条规则非常适合将子目录重定向到我的处理程序脚本,但也有一些真正的子目录(又名 /wp-admin 和 /contact)也被重定向到我的处理程序:

<rule name="Rewrite to article.aspx">
  <match url="^states/([a-z _]+)" />
  <action type="Rewrite" url="states.php?state={R:1}" />
</rule>

如何确保 /wp-admin 和 /contact 实际上进入真正的子目录,而其他所有内容都使用 URLrewrite 进入我的 cistom 处理程序?

【问题讨论】:

    标签: php iis mod-rewrite url-rewriting


    【解决方案1】:

    您可以在规则中添加条件——使用 IIS 管理器中的 URL 重写模块来帮助构建这些规则。或者,添加优先规则并在为真时停止处理。以下是一些可以直接剪切/粘贴到 web.config 中的规则:

    <rule name="pass wp-admin through" stopProcessing="true">
        <match url="^wp-admin/(.*)" />
        <action type="Rewrite" url="{R:0}" />
    </rule>
    <rule name="pass contact through" stopProcessing="true">
        <match url="^contact/(.*)" />
        <action type="Rewrite" url="{R:0}" />
    </rule>
    <!-- insert your other rules here-->
    

    【讨论】:

      猜你喜欢
      • 2020-05-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-02
      • 2012-09-30
      • 1970-01-01
      • 2013-02-09
      • 2013-01-10
      • 1970-01-01
      相关资源
      最近更新 更多