如何配置的.htaccess的CakePHP的文件WampServer?文件、htaccess、CakePHP、WampServer

2023-09-02 00:34:32 作者:伤丶半世流离

我绝对什么,我必须做些什么来运行我在CakePHP的样品迷茫......

我使用WAMP的服务器,它位于C:/程序文件/ WAMP /我用另一个分区为我的项目:E:/项目/".

有一个文件夹的学习CakePHP的: E:/项目/ CakePHP的/ 。我已经把该文件夹中的所有CakePHP中提取的内容(的包括:index.php文件的.htaccess,readme.txt文件和文件夹:应用程序,蛋糕,插件,厂商的)

首先,我设置的Apache是​​指一个别名(测试),以 E:/项目/ CakePHP的/ ,并没有工作(消息:哎呀这个链接似乎被打破的)

一些搜索后,我发现我必须设置别名到其他文件夹: E:/项目/ CakePHP的/应用程序/ Web根目录/ ,它完美地工作,给我的第一页的CakePHP的框架。

我解决了第一页的所有问题(使用CakePHP的手动的)。我试图按照CakePHP的博客教程......我做了一个模型,一个CONTROLER和视图页面(凡是涉及到上岗主题),但是当我尝试看看我刚刚收到WAMP服务器的第一页的结果(显示有在解决一些问题)

我使用的地址:的http://本地主机/测试/职位/指数(没有工作) 然后,我试图把index.php文件的URL:的http://localhost/test/index.php/posts/index !和它的工作

.htaccess文件,当我试图达到的根!的http://本地主机/测试/ 工作完美,我不知道什么是错

XX 我发现了同样的问题在计算器,here 。所有设置相似,除了雷看来他设置别名CakePHP的根,并没有为我工作!

实际上我怎么也找不到,我可以使用该解决方案(的链接),帮助他,因为我觉得这是我的情况有点不同了!

我的htaccess的文件以下CakePHP的文件夹,如下图所示。

根的CakePHP的

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    的RewriteBase /测试/
    重写规则^ $ /应用程序/ Web根目录/ [L]
    重写规则(。*)/程序/ Web根目录/ $ 1 [L]
< / IfModule>
 

/应用

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    的RewriteBase /测试/
    重写规则^ $ Webroot公司/ [L]
    重写规则(。*)根目录/ $ 1 [L]
 < / IfModule>
 

/应用程序/ Web根目录

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    的RewriteBase /测试/
    的RewriteCond%{} REQUEST_FILENAME!-d
    的RewriteCond%{} REQUEST_FILENAME!-f
    重写规则^(。*)$ /index.php?url=$1 [QSA,L]
< / IfModule>
 
天翼云盘目录索引php,天翼云盘文件同步与目录设置方法

我希望有人能帮助我,我真的筋疲力尽......

在此先感谢您的时间和您的解决方案!

-------------------------------------------------------------------------------

Yoohoooo!我找到了答案!我做了所有我的htaccess文件很多变化!如果你有这样的问题太多,先删除所有的更改,然后使用该链接是有很大的帮助! 希望它可以帮助你呢! CHEEEEERS! MANY CHEEEEERS! :D

解决方案 右键单击上的WAMP图标您 任务栏 然后将鼠标悬停在Apache模块 向下滚动,并确保rewrite_module打勾

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

解决方案

Right click on the WAMP icon on your task bar Then Hover over Apache Modules Scroll down and make sure rewrite_module is ticked