web.config无法使用子文件夹中的WordPress永久链接

pee*_*pee 4 iis wordpress web-config

我在根文件夹中的IIS服务器上安装了WP.这适用于非常永久链接.

还有另一个wordpress安装/development,使用以下web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
            <rule name="WordPress1" 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>
    <staticContent>
      <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
      <remove fileExtension=".woff"/>
      <remove fileExtension=".woff2"/>
      <mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/>
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
    </staticContent>

  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

但是,在子文件夹中,相当固定链接无法在此站点上运行

但是,当选择了普通永久链接时,主页可以使用此子文件夹

有什么想法吗?

小智 6

pee2pee说的答案是将该行放在代码中.

<remove name="YourRuleName"/>
Run Code Online (Sandbox Code Playgroud)

要执行此操作,您必须首先查看root的web.config文件并查找此行.

<rule name = "YourRuleName" patternSyntax = "Wildcard">
Run Code Online (Sandbox Code Playgroud)

然后复制目录或子文件夹的web.config文件中的行,将"YourRuleName"更改为您在第一个标记上方的根目录的web.config文件中找到的名称.

然后,您的子文件夹的web.config文件应该是这样的

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
            <remove name="YourRuleName"/>
            <rule name="YourSubFolderRuleName" 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>
Run Code Online (Sandbox Code Playgroud)

我希望它对我来说很有帮助.


pee*_*pee 3

确保根文件夹(为主站点提供服务)和子文件夹(辅助站点或 /shop 所在的位置)都有一个唯一的 web.config 文件。

\n\n

在子文件夹\xe2\x80\x99s web.config 文件中,您需要删除在根文件夹中设置的规则。在我们的例子中,根文件夹中的 WordPress 重写规则集称为 \xe2\x80\x9cPrimarySite\xe2\x80\x9d,因此在子文件夹 \xe2\x80\x99s web.config 中我们有:

\n\n
<remove name="PrimarySite"/>\n
Run Code Online (Sandbox Code Playgroud)\n\n

\xe2\x80\x99 就是让一切正常运转所需的一切。很简单,嗯?

\n