web.config规则相互冲突

时间:2018-08-20 12:31:27

标签: web-config

我正在运行IIS服务器,最近已从.asp迁移到.php。我为所有以.asp结尾的页面设置了重定向规则,以转到各自的.php页面,效果很好,但是现在我的各个页面重定向均无法正常工作,我的wordpress重定向规则也不起作用,因为添加它会使asp变成php规则这是最重要的。

这是我所拥有的片段

...                             

  <system.webServer>
  <rewrite>
    <rules>
    <rule name="Redirect ASP to PHP" stopProcessing="true">
                <match url="^(.*)\.asp$" />
                <action type="Redirect" url="{R:1}.php"  redirectType="Temporary" />
            </rule>

         <rule name="HTTP to HTTPS redirect" stopProcessing="true">
            <match url="(.*)" />
                 <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true"  />
                </conditions>
            <action type="Redirect" redirectType="Found"  url="https://{HTTP_HOST}/{R:1}" />
        </rule>


  <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="HTTP to HTTPS redirect" stopProcessing="true">
            <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
            <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
        </rule>

     </rules>
 </rewrite>

    <defaultDocument>
        <files>
            <clear />               
            <add value="index.php" />                          
 </files>
    </defaultDocument>
    <directoryBrowse enabled="false" /> 
    <httpRedirect enabled="false" destination="https://www.mysite.ca" />
    <httpErrors errorMode="Custom" />

0 个答案:

没有答案