【问题标题】:IIS php extension URL rewrite rule and wordpress in sub directory conflict子目录中的IIS php扩展URL重写规则和wordpress冲突
【发布时间】:2023-03-07 00:16:02
【问题描述】:

我将 wordpress 安装在主根文件夹中名为“blog”的子目录中,并在根文件夹中使用 .php 扩展名重写了 web.config URL。我在“博客”子目录中也有标准的 wordpress web.config 文件。

除了某些原因登录页面在登录时不断刷新,这让我相信存在冲突之外,所有工作正常。

会省略根 web.config 帮助中的“博客”目录吗?我试过了,但我收到的只是 500 个错误。

这里是根 web.config...

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect .php extension" stopProcessing="false">
  <match url="^(.*).php$" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
  <add input="{URL}" pattern="(.*).php$" ignoreCase="false" />
</conditions>
  <action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="hide .php extension" stopProcessing="true">
  <match url="^(.*)$" ignoreCase="true" />
<conditions>
  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  <add input="{REQUEST_FILENAME}.php" matchType="IsFile" />
  </conditions>
  <action type="Rewrite" url="{R:0}.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

这里是 blog/web.config...

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<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></rules>
</rewrite>
</system.webServer>
</configuration>

非常感谢任何想法。

【问题讨论】:

    标签: php wordpress iis url-rewriting


    【解决方案1】:

    我终于找到了解决这个问题的方法,现在它很有效。

    我添加了一条新规则以省略博客文件夹... <rule name="block" stopProcessing="true"> <match url="^blog/wp-login.php$" /> <action type="None" /> </rule>

    这解决了问题。该解决方案位于... How to exclude a directory with IIS URL rewriting

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-19
      • 1970-01-01
      • 2011-03-03
      • 2014-04-28
      • 2015-03-23
      • 2011-11-21
      相关资源
      最近更新 更多