gpt4 book ai didi

apache - 使用 .htaccess 控制 CakePHP 的重定向

转载 作者:行者123 更新时间:2023-12-02 08:17:48 26 4
gpt4 key购买 nike

我在Windows7+Apache2.2上安装了cakePHP并尝试了博客教程。

现在我一直把重定向控制与 .htaccess 混淆了。

我已按照教程的说明设置 .htaccess。

htdocs
.htaccess
app
.htaccess
webroot
.htaccess

每个 .htaccess 文件如下。

[在 htdocs 下]

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

[在应用程序下]

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

[在wabroot下]

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

但是发生了错误,这是 error.log 中的消息

client denied by server configuration: :/Apache2.2/htdocs/app/webroot/.htaccess

出了什么问题?

本教程应用程序使用以下 URL。

http://mydomain/posts/index   // show index page
http://mydomain/posts/view/3 //show an article selected from index(3 means ID number)
http://mydomain/posts/add //show a page for posting new articl
http://mydomain/posts/edit/3 //show a page for e
http://mydomain/posts/delete/3 //delete an article selected from index

.htaccess 当 URL 为/index 和/view/3 时通常控制重定向。

但是如果 URL 是/add 、/edit/3 和/delete apache 不会将它们重定向到 index.html 。 php.

实际上对文章的addeditdelete操作都成功处理。

并且添加编辑删除使用POST方法

我猜如果它的方法是POST重定向就会失败。

最佳答案

您的文件夹结构似乎不太好...您必须在 htdocs 下创建一个项目名称并将 Cakephp 文件复制到该文件夹​​。喜欢-

htdocs
--myapplication
.htaccess
-- app
.htaccess
-- webroot
.htaccess

关于apache - 使用 .htaccess 控制 CakePHP 的重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23072911/

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