如何在WampServer中配置CakePHP的.htaccess文件?
我对在 CakePHP 中运行示例必须做什么感到非常困惑...
我正在使用 WAMP 服务器,它位于“C:/program files/wamp/”中,我为我的项目使用另一个分区:“ E:/项目/”。
有一个用于学习 CakePHP 的文件夹:“E:/Projects/cakephp/”。我已将所有 CakePHP 提取的内容放入该文件夹中(包含:index.php、.htaccess、readme.txt 和文件夹:app、cake、插件、供应商)...
首先,我在 Apache 中设置一个指向“E:/Projects/cakephp/”的别名 (test),但它不起作用(消息:哎呀!此链接似乎已损坏。)
经过一番搜索,我发现我必须将别名设置为另一个文件夹:“E:/Projects/cakephp/app/webroot/”,并且它工作得很好,并向我展示了 CakePHP 框架的第一页。
我解决了第一页中的所有问题(使用 CakePHP 手册)。我尝试遵循 CakePHP 博客教程...我制作了一个模型、一个控制器和一个视图页面(所有这些都与“帖子”主题相关),但是当我尝试查看结果时,我刚刚收到了 WAMP 服务器的第一页(显示地址中有一些问题)
我使用的地址:“http://localhost/test/ posts/index”(这不起作用) 然后,我尝试将index.php放在url中:“http://localhost /test/index.php/posts/index”并且成功了!
.htaccess 文件,当我尝试到达根目录“http://localhost/test/“工作完美,我不知道出了什么问题!
xx 我在 StackOverflow 中发现了同样的问题,这里。它的所有设置都与我的类似,只是他似乎将别名设置为 CakePHP 的根目录,但它对我不起作用!
实际上我找不到如何使用该解决方案(链接)这对他有帮助,因为我认为我的情况有点不同!
我的以下 cakephp 文件夹的 htaccess 文件如下,
cakephp 的根
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /test/
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /test/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
我希望有人可以帮助我,我我真的很累...
提前感谢您的时间和解决方案!
--------------------------------------------------------- --------------------------------
哟哟哟!我找到了答案!我对所有 htaccess 文件进行了许多更改!如果您也遇到此问题,请首先删除所有更改,然后使用此 链接有很大帮助! 希望对你也有帮助!芝士们!很多芝士!! :D
I'm absolutely confused about what I must do to run my sample in CakePHP...
I'm using WAMP Server and it is located in "C:/program files/wamp/" and I use another partition for my projects: "E:/Projects/".
there is a folder for Learning CakePHP: "E:/Projects/cakephp/". I've put all the CakePHP extracted contents in that folder (consist of: index.php, .htaccess, readme.txt and folders: app, cake, plugins, vendors)...
First, I set an alias name (test) in Apache that pointed to "E:/Projects/cakephp/", and it didn't work (message: Oops! This link appears to be broken.)
After some search, I found that I must set the alias to another folder: "E:/Projects/cakephp/app/webroot/", and it worked perfectly and showed me the first page of CakePHP Framework.
I solved all the issues in the first page (using the CakePHP manual). I tried to follow CakePHP blog tutorial ... I made a model, a controler and a view page (all related to "posts" subject), but when I try to see the result I just received the first page of WAMP server (showing that there is some problem in the address)
I used the address: "http://localhost/test/posts/index" (that didn't work)
then, I tried to put index.php in the url: "http://localhost/test/index.php/posts/index" and it worked!
.htaccess files when I try to reach the root "http://localhost/test/" work perfect, I don't know what's wrong!
xx I found the same question in StackOverflow, here . All of its settings is similar to mine except it seems he set the alias to the root of CakePHP, and it didn't work for me!
and actually I couldn't find how I can use the solution (link) that helped him, because I think it is a little different in my case!
My htaccess files for following cakephp folders are as following,
root of the cakephp
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /test/
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /test/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
I hope someone can help me, I'm really exhausted...
thanks in advance for your time and your solutions!
-------------------------------------------------------------------------------
Yoohoooo! I found the answer! I had made many changes in all of my htaccess files! If you have this problem too, first remove all of your changes and then use this link as a great help!
Hope it help you too! CHEEEEERS! MANY CHEEEEERS!! :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
任务栏
task bar
其实我也遇到了和你一样的问题,但是不记得怎么解决的了。
我可以向您保证这不是 .htaccess 问题,而是 Apache 的配置错误。
我认为我修改的部分就是这个。
请注意我如何评论某些行。虽然我无法确认这一点,因为我没有默认的配置文件。
I actually got the same issue as you, but I don't remember how I solved it.
What I can assure you it's not a .htaccess issue, but a configuration error of Apache.
I think the part I modified was this one.
Note how I commented some lines. Altough I can't confirm this, since I don't have the default configuration file.
我遇到了同样的问题,这是对我有用的解决方案,
这是我在 wamp 服务器中的
cakephp.conf
这是 /cakephp 中的
.htaccess
文件(未更改任何内容)这是/cakephp/app 中的
.htaccess
文件(未更改任何内容)这是 /cakephp/app/webroot 中的
.htaccess
文件(已更改)行
我刚刚添加了这一 我能够启动 url localhost/cakephp/index.php/posts/index
希望这将帮助您使用 WAMP 服务器开始使用 CakePhp
I had same issue and here is solution that worked for me
this is my
cakephp.conf
in wamp serverThis is
.htaccess
file in /cakephp (not changed anything)This is
.htaccess
file in /cakephp/app (not changed anything)This is
.htaccess
file in /cakephp/app/webroot (changed)I just added line this line
After this I was able to launch url localhost/cakephp/index.php/posts/index
Hope this will help you to get started with CakePhp using WAMP Server
使用
use