当前位置: 首页 > 面试题库 >

.htaccess用于cakephp

劳韬
2023-03-14
问题内容

我正在尝试使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
/
),则会看到正确的页面。但是,即使加载了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

因此,我的 问题是 :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网站上列出。谢谢大家!



 类似资料:
  • 问题内容: 是否可以在中构建这样的代码? url显示路由不是“ view”,并且文件不存在,然后写入。 使用类似或 更新:我需要一个正则表达式的路线中。 问题答案: 最终结构为: 感谢大家。PD:使用模块ejs渲染html

  • 我正在努力使我的网站更加SEO友好,我目前正在使用 将转换为 我还想将其用于子页面。我试过这个: 但是它不工作,它运行,但是当您转到时,它返回未找到的404。 我希望它运行并返回 或 site.co.uk/page_name/sub_page并返回sub_page 等等等等

  • 问题内容: 我没有运气让我的.htaccess与mod_rewrite一起工作。基本上,我要做的就是从“ http://www.example.com ”和“ https://www.example.com ”中删除“ www ”。 如果我缺少任何内容(conf文件等,请通知我,我将对此进行更新) 这是我的.htaccess文件(位于@ / var / www / site / trunk / h

  • 问题内容: 我已经使用SLIM PHP框架创建了一个基本的RESTful服务,现在我正尝试将其连接起来,以便可以从Angular.js项目访问该服务。我已经了解到Angular开箱即用地支持CORS,而我要做的就是在我的.htaccess文件中添加以下行: 我已经做到了,我的REST应用程序仍然可以正常工作(.htaccess错误导致500个内部服务器没有错误),但是当我尝试从test- cors

  • 我用CodeIgniter和几个控制器构建了一个应用程序 除了在应用/配置/routes.php文件中设置为默认的控制器之外,所有控制器似乎都工作正常 我的. htaccess文件看起来像这样: 重写引擎在 RewriteBase/ RewriteCond%{REQUEST_FILENAME}上-重写cond%{REQUEST_FILENAME}-d 重写规则^(.*)$/索引。php/$1[L]

  • 我在根目录中有一个htaccess文件,在电影文件夹中有另一个htaccess文件。我想停止所有重写URL或影响“电影”文件夹的条件。我在电影文件夹访问中有一些其他规则。 我的根访问权限如下所示 我的子目录电影文件夹htaccess 上面的代码只是我最初的htaccess的一部分