php - 如何将 .htaccess 文件中的条件转换为 web.config
问题描述
我有这个 .htaccess 文件:
RewriteCond %{REQUEST_URI} !/admin/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^(.*)$ rewrite.php
如何在 web.config 文件中重写它?
解决方案
尝试这个
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="/admin/" ignoreCase="false" negate="true" />
<add input="{THE_REQUEST}" pattern="^[A-Z]{3,}\s([^.]+)\.php" />
</conditions>
<action type="Rewrite" url="rewrite.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
推荐阅读
- amazon-web-services - 单个 AWS 组织中的多个 Root 账户:IAM 管理员无法查看指定区域中的所有 EC2 实例
- python - 如何将列表从 python 传递给 jython 返回结果给 python
- ruby-on-rails - 在活动记录中出现密码存在两个错误
- python - 在终端中调用“python3”时如何停止 Python 2.7 运行?
- java - 在 ANT 构建期间未发送修改的文件
- javascript - 在外部 .js 文件的 Angular 7 项目中包含 JQuery-Ui
- c# - 对控制器的 Ajax 调用导致 400 错误
- php - 获取2个数组之间的差异
- matlab - 如何在 Matlab 中识别时间序列数据中的重复模式
- android - 为什么我会收到错误“ArrayIndexOutOfBoundsException:长度=0;索引=0”?