【发布时间】:2019-08-09 23:28:03
【问题描述】:
我已经在 microsoft window server 6.2 IIS service 8.5 上安装了 cakephp 2.6 版本 因为我已经在 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
但我需要漂亮的 parmalink URL,例如 https://www.baseurl.com/blog/hello-world/
我为此搜索了很多文章也找到了很多但没有答案是使用 cakephp 使用窗口服务器 你们都知道.htacces 在 iis 8 上不起作用,所以我在 cakephp 的根文件夹中创建 web.config 文件
|_ cakePHP
| |_ app
| |_ blog
| |_ lib
| |_plugins
| |_web.config
根文件夹的代码/上面的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 服务器,其余部分无法正常工作,所以请帮助我解决这个问题。希望得到完整的答案谢谢
您也可以参考下面的链接来澄清我的问题,因为它可以通过 .htaccess 实现,但我无法找到 iis 服务器 web.config 的答案
【问题讨论】:
-
尽量让像 wordpress 这样的安全威胁远离任何适当的框架。也许把它放在一个子域上并重定向到那个。至少那是我会在你的情况下做的事情。但是你可以把整个博客文件夹放在你的 webroot 文件夹中,从那里开始路径应该会更好,我猜我还没有测试过。
标签: wordpress cakephp iis-8 cakephp-2.6 window-server