iis - IIS 将规则全部重写到 index.php,除了 /edit 目录
问题描述
您好,我正在尝试这样做,所以当我输入 url /edit 然后将我放入目录 /edit 中。其他一切都只在 index.php
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="(\.png|\.jpg|\.gif|\.jpeg|\.js|\.css|\.ico|\.mp4|captcha.php|servertime.php|robots.txt)$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
当前,此代码将所有内容重定向到 index.php 当我添加时:
<rule name="Imported Rule 1-1" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^edit/?(.*)$" />
<action type="Rewrite" url="edit/index.php" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="index.php" />
</rule>
目录 /edit 打开,但我失去了另一个重定向全部到 index.php
解决方案
您需要一个新的“规则”,只需确保在其他规则之前添加它:)
<rule name="rule1" stopProcessing="true">
<match url="^edit" />
<action type="None" />
</rule>
推荐阅读
- javascript - 我该如何创造这样的东西?
- python - 合并多行输出?
- javascript - 如何在 Unobtrusive Javascript onclick 分配中使用变量?
- react-leaflet - React Leaflet V3 自定义控件
- reactjs - 使用上下文不会更新反应状态?
- c# - 在 C# .NET 中,Directory.GetDirectories 或 Directory.GetFiles 不能从哪些目录获取目录或文件,为什么?
- xamarin - RestSharp GET 错误请求
- flutter - 在 Onboard Pages 上进行 Flutter 应用程序初始化?
- php - 在 meta property="og:url" 中未显示完整的 url
- java - 如何使用 org.json 写入 json