cakephp 的 .htaccess [英] .htaccess for cakephp

查看:31
本文介绍了cakephp 的 .htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to get a CakePHP application to work. For this, I've set up a brand new Debian installation, updated the configuration and put everything in /var/www, which has the following content:

app
cake
.htaccess
index.php
vendors

.htaccess 文件包含以下内容:

The .htaccess file contains the following:

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

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

If I access my virtualhost (http://myhost/) I see the correct page. But even the JavaScript loaded with src="/js/validate.js" fails (it's located within /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

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

Hence my question: what is the correct .htaccess required for CakePHP?

非常感谢!

推荐答案

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

The answer is that there are 3 different .htaccess files:

/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 网站上.谢谢大家!

It's been my fault, everything is listed on the CakePHP site. Thanks to everyone!

这篇关于cakephp 的 .htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆