【发布时间】:2017-10-08 11:56:57
【问题描述】:
将我的 CakePHP v2.2 应用程序从 linux 服务器复制到 Azure 应用程序服务以进行开发/测试。我知道.htaccess 不起作用,所以我在每个文件夹\ 和\app\ 和\app\webroot\ 中添加了一个web.config。网站的根目录工作,主页加载,从 SQL 读取数据,CSS 和 JS 加载。 CSS 文件托管在\app\webroot\css,但通过example.com\css\file.css 访问,所以我假设某种重写工作正常。
问题是当转到一个页面时,即example.com/about,我收到错误The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
我在这里看到了大多数(如果不是全部)关于在 IIS 上托管它的帖子,我再次认为我的 web.configs 在那里。我错过了什么?
\中的web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule1A" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="app/webroot/" />
</rule>
<rule name="rule2A" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="app/webroot/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
\app\中的web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="rule 1A" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="webroot/" />
</rule>
<rule name="rule 2A" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="webroot/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
\app\webroot\中的web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="CakePHP" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<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>
【问题讨论】:
标签: cakephp mod-rewrite cakephp-2.0