Apache 使用.htaccess控制CakePHP的重定向
我已经在Windows7+Apache2.2上安装了cakePHP,并尝试了博客教程 现在我把重定向控制和.htaccess混淆了Apache 使用.htaccess控制CakePHP的重定向,apache,.htaccess,cakephp,mod-rewrite,post,Apache,.htaccess,Cakephp,Mod Rewrite,Post,我已经在Windows7+Apache2.2上安装了cakePHP,并尝试了博客教程 现在我把重定向控制和.htaccess混淆了 htdocs .htaccess app .htaccess webroot .htaccess 我已经按照教程的说明设置了.htaccess htdocs .htaccess app .htaccess webroot .htaccess 下面是每个.htaccess文件 [在
htdocs
.htaccess
app
.htaccess
webroot
.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>
怎么了
本教程应用程序使用以下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.php
实际操作中,add
、edit
和delete
的文章处理成功
和添加
,编辑
和删除
使用发布
方法
我想如果它的方法是后重定向,那么它将失败。您的文件夹结构似乎不太好。。。您必须在htdocs下创建一个项目名称,并将Cakephp文件复制到该文件夹中。像-
htdocs
--myapplication
.htaccess
-- app
.htaccess
-- webroot
.htaccess
我粘贴了错误的列表。我修复了问题中的列表。你问题的最后部分不可理解。。。你能说清楚吗…我一直在尝试这个网址。此程序使用
post
、view
、add
、edit
和delete
作为文档操作。最后一部分是描述哪些操作被正常重定向或否。请求的头是什么?我看不到请求头。我的意思是我不能打印头变量的值,因为请求很快重定向到/app/webroot
目录,并显示该目录下的文件列表Index/app/webroot父目录css/favicon.ico files/img/Index.php js/
I将webroot
下的htaccess
更改为RewriteCond%{REQUEST\u URI}-已重写cond%{REQUEST_URI}-f
。现在,它被正常重定向。但我不知道为什么。
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
htdocs
--myapplication
.htaccess
-- app
.htaccess
-- webroot
.htaccess