htaccess到web.config文件rewriteCond

时间:2012-11-12 14:19:29

标签: mod-rewrite web-config

我有这个htaccess,它会在url中添加文件夹并将其转换为变量。如下:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?pagina=$1

我必须将其转换为web.config xml sctructured文件,它的工作原理如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1">
                    <match url="^([a-zA-Z0-9_-]+)$" ignoreCase="false" />
                    <action type="Rewrite" url="/index.php?page={R:1}" appendQueryString="false" />
                </rule>
                <rule name="Imported Rule 2">
                    <match url="^([a-zA-Z0-9_-]+)/$" ignoreCase="false" />
                    <action type="Rewrite" url="/index.php?page={R:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

现在我只需要在最后一个文件夹不是特定文件夹时才能使它工作,我在研究后尝试了这个但没有成功:

<conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_URI}" pattern="!^/diretorio/" ignoreCase="true" />
</conditions>

1 个答案:

答案 0 :(得分:0)

我发现正确的代码是:

<conditions>
     <add input="{REQUEST_URI}" pattern="^/admin/" ignoreCase="false" negate="true" />
</conditions>