如何将 .htaccess 文件中的条件转换为 web.config
How to convert conditions in .htaccess file to 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>
我有这个 .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>