简体   繁体   English

IIS php扩展URL重写规则和子目录中的wordpress冲突

[英]IIS php extension URL rewrite rule and wordpress in sub directory conflict

I have wordpress installed in a sub directory called 'blog' in the main root folder, and a web.config URL rewrite to detail with the .php extension in the root folder. 我在主根文件夹中的子目录“ blog”中安装了wordpress,并在根文件夹中重写了一个web.config URL以使用.php扩展名进行详细说明。 I also have the standard wordpress web.config file in the 'blog' sub directory. 我还在'blog'子目录中有标准的wordpress web.config文件。

All works except for some reason the login page keeps refreshing itself on login which leads me to believe there is a conflict. 除了某些原因外,所有工作都可以进行,登录页面在登录时会不断刷新,这使我认为存在冲突。

Would omitting the 'blog' directory in the root web.config help? 会在根web.config帮助中省略'blog'目录吗? I have tried but all I receive is 500 errors. 我已经尝试过,但是我收到的只是500个错误。

Here is the root web.config... 这是根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>

And here is the blog/ web.config... 这是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>

Any ideas much appreciated. 任何想法表示赞赏。

I finally found a solution to this issue and it now works a treat. 我终于找到了解决这个问题的方法,现在可以解决了。

I added a new rule to omit the blog folder... <rule name="block" stopProcessing="true"> <match url="^blog/wp-login.php$" /> <action type="None" /> </rule> 我添加了一条新规则以忽略博客文件夹... <rule name="block" stopProcessing="true"> <match url="^blog/wp-login.php$" /> <action type="None" /> </rule>

This overcame the issue. 这样就解决了这个问题。 This solution was found at... How to exclude a directory with IIS URL rewriting 在以下位置找到此解决方案: 如何使用IIS URL重写排除目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM