gpt4 book ai didi

.htaccess - Windows IIS7 上的 Htaccess 和 CakePHP 2

转载 作者:行者123 更新时间:2023-12-04 12:30:10 26 4
gpt4 key购买 nike

我在尝试通过 Windows 和 II7 配置模组重写时遇到问题: CakePHP 2.2.2 not working on Windows IIS7但最后我可以导入 htaccess 以便为 IIS7 创建 web.config 文件。

事情是:现在该文件已在 cakephp 文件夹中创建,我可以访问主页但是它尚未在 app/app/webroot 在其中您可以找到另外 2 个 .htaccess 文件。

现在,除了主站点,我无法访问任何其他 View ,它显示 404 页面未找到错误,我很确定这是因为它没有在 web.config 上获取那些 .htaccess 文件。

我的 cakephp web.config 文件如下所示:

<?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>
</rules>
</rewrite>
</system.webServer>
</configuration>

虽然 CakePHP 文档告诉您添加不同的代码(这使得 View 可以工作但没有加载样式。主页也不起作用。) http://book.cakephp.org/2.0/en/installation/advanced-installation.html#url-rewrites-on-iis7-windows-hosts

当尝试从 URL 访问 CSS 文件时,我收到此消息:

Missing Controller

Error: CssController could not be found.

Error: Create the class CssController below in file: app\Controller\CssController.php

<?php
class CssController extends AppController {

}

有什么想法吗?在 Windows 上使用 Cakephp 使我发疯...

最佳答案

我应该指出,我的回复是对此处发布的解决方案的改进:http://www2.palomar.edu/pages/sphillips/cakephp-with-iis-7-rewrite-rules-in-a-sub-folder/

一个更简单、更灵活的修复方法是完全删除 /{Path_To_CakePHP_Directory}/,包括正斜杠 (/)。通过保持路径相对,您的项目文件夹变得更加移动。下面是 web.config 的样子:

 <configuration>
<system.webServer>
<rewrite>
<rules>
<clear/>
<rule name="Imported Rule 0" stopProcessing="true">
<match url="^(img|css|files|js)(.*)$"></match>
<action type="Rewrite" url="app/webroot/{R:1}{R:2}" appendQueryString="false"></action>
</rule>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="app/webroot/" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="app/webroot/{R:1}" />
</rule>
<rule name="Imported Rule 4" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

关于.htaccess - Windows IIS7 上的 Htaccess 和 CakePHP 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12497904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com