【问题标题】:How to convert conditions in .htaccess file to web.config如何将 .htaccess 文件中的条件转换为 web.config
【发布时间】:2018-05-24 13:18:18
【问题描述】:

我有这个 .htaccess 文件:

RewriteCond %{REQUEST_URI} !/admin/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^(.*)$ rewrite.php

如何在 web.config 文件中重写它?

【问题讨论】:

    标签: php .htaccess iis web-config


    【解决方案1】:

    试试这个

    <?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>
    

    【讨论】:

      猜你喜欢
      • 2017-12-01
      • 2017-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多