web.config-第二个URL重写规则不起作用

问题描述 投票:0回答:1

我的wordpress有2条URL重写规则,这是第一条规则:

<rule name="wordpress" patternSyntax="Wildcard">
    <match url="*"/>
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
        </conditions>
    <action type="Rewrite" url="index.php"/>
</rule>

这是第二条规则:

<rule name="Redirect to https" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>

他们俩都独立工作。但是,如果我将以下两个规则结合起来:

<rewrite>
    <rules>
        <rule name="wordpress" patternSyntax="Wildcard">
            <match url="*"/>
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                </conditions>
            <action type="Rewrite" url="index.php"/>
        </rule>

        <rule name="Redirect to https" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>

仅第一条规则有效,第二条规则被忽略,就好像它不存在一样。如何使第二条规则与第一条规则一起使用?

iis web-config
1个回答
0
投票

您可以尝试使用此规则:

© www.soinside.com 2019 - 2024. All rights reserved.