首页 > 解决方案 > 如何 FIX 在 WordPress 上为 Azure 上的 IIS 服务器选择永久链接结构

问题描述

需要你的帮助。Azure 中有一个 IIS 服务器。它包含网站和 Angular SPA 应用程序。我需要在一个单独的目录中安装 WordPress 博客。博客展开。但是选择永久链接结构存在问题。

我有一个错误:403 - 禁止访问:访问被拒绝。提供给您的凭据。

我有两个 web.config 文件 1. ROOT web.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <location path=".">
            <system.webServer>
                <security>
                    <authentication>
                        <anonymousAuthentication enabled="true" />
                    </authentication>
                </security>
                <rewrite>
                    <rules>
                        <clear />
                        <rule name="Redirect http to https" stopProcessing="true">
                            <match url=".*" />
                            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                                <add input="{HTTPS}" pattern="^OFF$" />
                            </conditions>
                            <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" />
                        </rule>
                        <rule name="login redirect" patternSyntax="ECMAScript" stopProcessing="true">
                            <match url="^login" />
                            <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                            <action type="Redirect" url="ANGULAR-SPA-DIR/login" />
                        </rule>
                        <rule name="AngularJS Routes" stopProcessing="true">
                            <match url=".*" />
                            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                                <add input="{REQUEST_URI}" matchType="Pattern" pattern="/ROOT-DIR/" ignoreCase="true" negate="true" />
                                <add input="{REQUEST_URI}" matchType="Pattern" pattern="/ANGULAR-SPA-DIR/" ignoreCase="true" negate="true" />
                                <add input="{REQUEST_URI}" matchType="Pattern" pattern="/TEST/" ignoreCase="true" negate="true" />
                            </conditions>
                            <action type="Rewrite" url="/index.html" />
                        </rule>
                        <rule name="AngularJS Routes1" stopProcessing="true">
                            <match url="^ANGULAR-SPA-DIR/" />
                            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                            </conditions>
                            <action type="Rewrite" url="/ANGULAR-SPA-DIR/index.html" />
                        </rule>
                        <rule name="AngularJS Routes2" stopProcessing="true">
                            <match url="^TEST/" />
                            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                            </conditions>
                            <action type="Rewrite" url="/TEST/index.html" />
                        </rule>
                        <rule name="WordPress Blog" stopProcessing="true">
                            <match url="blog/.*" />
                            <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                                <add input="{REQUEST_FILENAME}" matchType="IsFile" />
                                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
                            </conditions>
                            <action type="None" logRewrittenUrl="true" />
                        </rule>
                    </rules>
                </rewrite>
                <caching>
                    <profiles>
                        <add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="00:30:00" />
                        <add extension=".svg" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="01:00:00" />
                        <add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="01:00:00" />
                        <add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="00:30:00" />
                        <add extension=".woff2" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="24.00:00:00" />
                    </profiles>
                </caching>
                <directoryBrowse enabled="true" />
            </system.webServer>
        </location>
    </configuration>
  1. 博客 web.config
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules><remove name="WordPress Blog"/>
                <rule name="WordPress: https://ROOT-URL/blog" 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>

有什么经验的朋友可以推荐一下?

标签: wordpressazureiis

解决方案


将 srting 添加到 ROOT web.config

<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
...
<add input="{QUERY_STRING}" pattern="/blog/" />
</conditions>

之后,他们“选择你的永久链接结构”正常工作


推荐阅读