简体   繁体   中英

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):

/
/wp_one
/wp_two

All of them have a web.config. If I remove the web.config from the root directory, URLs in children wp works pretty well. 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.

web.config content (they have the same content):

<?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.

In order to fix this you will have to make your paths relative based on the topmost web.config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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