【发布时间】:2017-04-17 18:26:44
【问题描述】:
我第一次在 IIS 服务器上使用 CakePHP3。
我已将 .htaccess 文件翻译成 webconfig 并将其放在我的项目目录的根目录下。
之后我就可以访问我的主页了。
主页:- 控制器:- 主页和操作:- route.php 中的索引:-
$routes->connect('/', ['controller' => 'Home', 'action' => 'index', 'index']);
但是当我尝试访问其他控制器example(/cakephp/dashboard/profile) 的操作时,问题来了:-
当我尝试访问仪表板控制器的配置文件操作时,它给了我 404 not found 错误。相同的代码在使用 .htaccess 的 Linux 上也能正常工作。
当我在controller(/cakephp/index.php/dashboard/profile) 之后手动添加 index.php 时,它工作正常。
谁能帮我解决这个问题?
这里是项目目录:- /httpdocs/cakephp/ 在此之下,我创建了一个 web.config 文件:-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear/>
<rule name="Exclude direct access to webroot/*" stopProcessing="true">
<match url="^webroot/(.*)$" ignoreCase="false" />
<action type="None" />
</rule>
<rule name="Rewrite routed access to assets(img, css, files, js, favicon)" stopProcessing="true">
<match url="^(img|css|files|js|favicon.ico)(.*)$" />
<action type="Rewrite" url="webroot/{R:1}{R:2}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="webroot/" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="webroot/{R:1}" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
-
你好,Shawaz,我也遇到了这个问题,你解决了吗?或者其他人有什么想法吗?
标签: php cakephp iis url-rewriting cakephp-3.0