wordpress 安装在 iis window 服务器上的 cakephp 子文件夹中

wordpress installed in cakephp subfolder on iis window server

我在微软安装了cakephp 2.6版本window server 6.2 IIS service 8.5 因为我已经在 app 文件夹

下的子目录中安装了 wordpress 博客
|_ cakePHP
|     |_ app
|     |_ blog
|     |_ lib
|     |_plugins

在 cakephp 应用程序中一切正常工作,wordpress 博客也能正常工作 如果我们点击 baseurl/blog/ 就好了 索引页显示正确。

但是当我们更改 wordpress 博客中的设置时,parmalink 设置并使 prety url 像 https://www.baseurl.com/blog/hello-world/ 它给出 404 错误,但它与普通的 url 一起工作 https://www.baseurl.com/blog/?p=1

但我需要漂亮的帕尔玛link URL https://www.baseurl.com/blog/hello-world/

我为此搜索了很多文章也找到了很多但没有答案正在使用带有 cakephp 的 window 服务器 众所周知,.htacces 在 iis 8 上不起作用,所以我在 cakephp

的根文件夹中创建 web.config 文件
|_ cakePHP
|     |_ app
|     |_ blog
|     |_ lib
|     |_plugins
|     |_web.config

root folder/above web.config 的代码是

   <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>

                    <!--# Exclude requests already going to /subfolder to avoid an infinite loop-->
                    <rule name="Imported Rule 1" stopProcessing="true">
                        <match url="^blog.*$" />
                        <action type="None" />
                    </rule>


                    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTPS}" pattern="^OFF$" />
                        </conditions>
                        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
                    </rule>

                    <rule name="Exclude direct access to app/webroot/*" stopProcessing="true">
                        <match url="^app/webroot/c$" ignoreCase="false" />
                        <action type="None" />
                    </rule>
                    <rule name="Rewrite routed access to assets(geet_jewellery,img, css, files, js, favicon)" stopProcessing="true">
                        <match url="^(blog|buyanddelight|crm_geet|geet_jewellery1|geet_jewellery|img|css|files|js|favicon.ico)(.*)$" />
                        <action type="Rewrite" url="app/webroot/{R:1}{R:2}" appendQueryString="false" />
                    </rule>
                    <rule name="Rewrite requested file/folder to index.php" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <action type="Rewrite" url="index.php" appendQueryString="true" />
                    </rule>


                </rules>
            </rewrite>
            <httpErrors errorMode="Custom" defaultPath="C:\Inetpub\wwwroot\Indexhome_.htm">
                <error statusCode="403" subStatusCode="4" path="C:\Inetpub\wwwroot\Indexhome_.htm" responseMode="File" />
            </httpErrors>
        </system.webServer>
    </configuration>

和web.config放在博客目录的根文件夹中,所有wordpress文件都在下面

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
            <rule name="WordPress: https://www.buyanddelight.com/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>

我找到了很多答案,但都不完整,因为其中一些没有 cakephp,一些没有 wordpress,一些没有 IIS 服务器 rest 无法正常工作,所以请帮我解决这个问题。希望得到完整的答案谢谢

您也可以参考下面 link 来澄清我的问题,因为它可以通过 .htaccess 实现,但我无法找到 iis 服务器的答案 web.config

enter link description here

好问题,欢迎来到 SO!在这种情况下,我会将 Wordpress 从您的 CakePHP 库中移走。您的 CakePHP 环境将变得极度脆弱。 Wordpress 有一些安全漏洞,当您将其作为子文件夹保存时,这些漏洞会影响您的 CakePHP 环境。文件包含、SQL 注入、跨站点脚本和恶意软件通常与肮脏的插件和主题一起出现。

最后我找到了对我有用的答案,下面是在 iis 服务器上对我有用的代码。在 blog 文件夹下创建一个 web.config 文件并放入以下代码

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <clear />
                <rule name="WordPress Rule" 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" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
            <outboundRules>
                <clear />
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>