我一直在尝试使用根文件夹中的以下 web.config 设置来获取重写规则以在 CakePHP 的 IIS 上工作:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="app/webroot/" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="app/webroot/{R:1}" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="webroot/" />
</rule>
<rule name="Imported Rule 4" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="webroot/{R:1}" />
</rule>
<rule name="Imported Rule 5" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
所有的 CSS、JS 和其他文件都可以正常工作。与在主页中加载一样,但其他页面如/pages/about
仅显示 404!
编辑: IIS 中设置的屏幕截图:
有什么问题?谢谢