我已经在 microsoft window server 6.2 IIS service 8.5 上安装了 cakephp 2.6 版本,因为我已经在 app 文件夹下的子目录中安装了 wordpress 博客
|_ cakePHP
| |_ app
| |_ blog
| |_ lib
| |_plugins
如果我们点击 baseurl/blog/ 索引页面正确显示,那么 cakephp 应用程序中的每件事都可以正常工作,wordpress 博客也可以正常工作。
但是,当我们更改 wordpress 博客 parmalink 设置中的设置并制作像 https://www.baseurl.com/blog/hello-world/这样的漂亮网址 时,它会给出 404 错误,但它使用像 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 的答案