.htaccess 用于 cakephp

2024-01-03

我正在尝试让 CakePHP 应用程序正常工作。为此,我设置了一个全新的 Debian 安装,更新了配置并将所有内容放入 /var/www 中,其中包含以下内容:

app
cake
.htaccess
index.php
vendors

.htaccess 文件包含以下内容:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    /webroot/ [L]
    RewriteRule    (.*) /webroot/$1 [L]
</IfModule>

如果我访问我的虚拟主机(http://myhost/ http://myhost/)我看到了正确的页面。但即使 JavaScript 加载了src="/js/validate.js"失败(它位于/var/www/app/webroot/js/validate.js):

[Wed Aug 26 15:45:12 2009] [error] [client 10.7.10.52] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Aug 26 15:45:12 2009] [debug] core.c(3063): [client 10.7.10.52] r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /webroot/js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] core.c(3069): [client 10.7.10.52] redirected from r->uri = /js/prototype.js
[Wed Aug 26 15:45:12 2009] [debug] mod_deflate.c(632): [client 10.7.10.52] Zlib: Compressed 649 to 405 : URL /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js

因此我的question:CakePHP 所需的正确 .htaccess 是什么?

非常感谢!


答案是有 3 个不同的 .htaccess 文件:

/var/www/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

/var/www/app/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

/var/www/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

都是我的错,一切都列在了CakePHP 站点 http://book.cakephp.org/2.0/en/installation/url-rewriting.html。谢谢大家!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

.htaccess 用于 cakephp 的相关文章

  • 提交ajax表单并停留在同一页面不起作用

    我想将用户的评论存储在我的数据库中 当用户提交时 我不想将他们重定向到新页面 我有以下代码 但它不起作用 我的 HTML 代码
  • 用于分页的php示例脚本[关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 任何人都可以建议一个好的分页 php 脚本 其中人们想要分页显示数据库中的大量项目 以下链接可以帮助您
  • PHP 有效读取 csv 文件

    有几种使用 PHP 读取 CSV 文件的方法 我以前用过explode函数将每一行放入一个数组中 然后explode逗号并使用trim删除数据周围的任何引号 本来就很乱 PHP 5 现在有fgetcsv和 str getcsv 我猜这是这些
  • 在 symfony2 中为特定控制器设置 max_execution_time

    Using ini set 我可以扩展最大执行时间一个脚本的 在Symfony2 我可以添加ini set to web app php and web app dev php将增加的执行时间应用于所有控制器 但在这种情况下 我只想扩展最大
  • 如何在Web服务中传递URL

    我想将此 URL 作为网址中的值传递http localhost h2orn php verify php email emails hash hash但是 我只能在 符号之前传递 我想传递所有 URL 我正在使用java网络服务 代码在这
  • PSR-4 代码库中条令生成器的解决方法

    在 Windows 机器上使用 Symfony 2 和 Doctrine 我正在尝试 从现有模式生成实体 php app console doctrine mapping import force CoreBundle annotation
  • 如何将 ctype_alpha 与 UTF-8 结合使用

    如何将 ctype alpha 与 UTF 8 一起使用 我有这个代码 if empty POST false if isset POST first name empty POST first name if ctype alpha PO
  • PHP 中的正则表达式:找到第一个匹配的字符串

    我想在非常长的文本中找到第一个匹配的字符串 我知道我可以使用 preg grep 并获取返回数组的第一个元素 但是 如果我只需要第一场比赛 或者我知道提前只有一场比赛 那么这样做效率不高 有什么建议吗 预匹配 http www php ne
  • SimpleSAMLPHP 重定向循环

    我们正在尝试使用自定义 mysql 数据库设置 sso 但它在以下两个请求之间进入无限循环 POST http 192 168 0 15 simplesaml module php core loginuserpass php 设置Cook
  • cURL '格式错误的网址'

    This url 在浏览器中工作得很好 但 cURL 返回错误 3 格式错误的 url 关于解决方法有什么想法吗 EDIT 卷曲代码 function get web page url options array CURLOPT RETUR
  • 如何在 joomla 模块中通过 javascript 发送输入文件类型

    我想将带有 javascript 的文件发送到 php 文件 我的 php 文件中有这个表单
  • 疯狂的 crond 行为。不断使 bash 进程失效

    我有一个看起来像这样的 crontab SHELL bin bash PATH sbin bin usr sbin usr bin MAILTO root HOME 0 59 var www html private fivemin zda
  • 如何覆盖 phpunit 中导出的变量?

    我知道我可以设置环境变量 https phpunit de manual current en appendixes configuration html在我的 phpunit xml 里面
  • 避免 SQLite3 中的 SQL 注入

    我正在尝试找出一种避免 SQL 注入的好简单方法 到目前为止我只能提出两个想法 对用户输入进行 Base64 编码 其实不想这样做 使用正则表达式删除不需要的字符 目前正在使用这个 不确定是否100 安全 这是我当前的代码
  • 无需下载整个文件即可读取 ID3 标签

    是否可以读取 MP3 文件的 ID3 标签 持续时间 艺术家 标题 而无需下载整个文件 我做了一些测试 只需下载 MP3 文件的几个字节就可以获得艺术家和标题标签 但我不确定持续时间和其他标签是否可能 Thanks 我刚刚发现 ffmpeg
  • 如何使用 PDO 动态构建查询

    我正在使用 PDO 并想做这样的事情 query dbh gt prepare SELECT FROM table WHERE column value query gt bindParam table tableName query gt
  • PHP - 查找和比较日期

    你好 我有 foreach 我可以在其中获取数据库中的事件数据 我使用数据库中的日期名称 例如 event date 我需要在一个 div 中比较具有相同日期和输出的操作 例如我有这个事件 活动一 9 月 13 日 活动二 9 月 1 日
  • PHP 除法浮点值问题

    当我尝试获取余数时 它给出了无效值 我试图获得两位小数的余数 我得到 3 4694469519536E 18 我的价值观是 x 0 1 y 0 005 我尝试了以下方法 echo ed fmod 0 1 0 005 OutPut 3 469
  • 处理查询字符串参数时 Codeigniter 缓存问题

    问候 我正在编写一个 CI Web 应用程序 它实现标准文件缓存功能 如下所示 this gt output gt cache n 我使用了段和查询字符串参数的组合 因此似乎遇到了问题 我在用例和输出类代码中看到的是 缓存仅基于段 像这样
  • PHP 中的 Zip 流

    我有一个 PHP 脚本 可以动态创建 zip 文件并强制浏览器下载该 zip 文件 问题是 我可以直接将zip文件写入连接到用户浏览器的输出流 而不是先将其保存为服务器上的真实文件 然后发送文件吗 提前致谢 如果您的 Web 服务器运行的是

随机推荐