简体   繁体   English

子目录中的web.config不适用于根目录中的web.config

[英]web.config in subdirectories doesn't work with web.config presence in root directory

I have 3 Wordpress installation on my webserver, one in the root folder, 2 in sub directories (iis): 我在Web服务器上安装了3个Wordpress,一个在根文件夹中,两个在子目录(iis)中:

/
/wp_one
/wp_two

All of them have a web.config. 他们都有一个web.config。 If I remove the web.config from the root directory, URLs in children wp works pretty well. 如果我从根目录中删除web.config,则子wp中的URL效果很好。 If I add it again, links point to the right place but when you click, I`m redirected to the correspondent page on root. 如果我再次添加它,链接指向正确的位置,但是当您单击时,我将重定向到根目录上的相应页面。 For example: www.site.com/wp_one/contact redirects to www.site/contact. 例如:www.site.com/wp_on​​e/contact重定向到www.site/contact。

web.config content (they have the same content): web.config内容(它们具有相同的内容):

<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
    <system.webServer>
      <rewrite>
        <rules>
          <rule name="wp" stopProcessing="true">
            <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>

When you have multiple config files they are merged into a single one during runtime. 当您有多个配置文件时,它们会在运行时合并到一个文件中。 This said when you have a web.config in your root the child ones are merged inside and since your paths are not relative they become invalid. 这就是说,当您在根目录中有一个web.config时,子目录将合并到其中,并且由于您的路径不是相对路径,因此它们将变为无效。

In order to fix this you will have to make your paths relative based on the topmost web.config. 为了解决这个问题,您将必须基于最顶层的web.config使路径相对。

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

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