如何在 WampServer 中配置 CakePHP 的 .htaccess 文件? [英] How to config .htaccess files of CakePHP in WampServer?

查看:23
本文介绍了如何在 WampServer 中配置 CakePHP 的 .htaccess 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对在 CakePHP 中运行我的示例必须做什么感到非常困惑......

I'm absolutely confused about what I must do to run my sample in CakePHP...

我正在使用 WAMP 服务器,它位于C:/program files/wamp/",我的项目使用另一个分区:E:/Projects/".

I'm using WAMP Server and it is located in "C:/program files/wamp/" and I use another partition for my projects: "E:/Projects/".

有一个用于学习 CakePHP 的文件夹:E:/Projects/cakephp/".我已将所有 CakePHP 提取的内容放在该文件夹中(包括:index.php、.htaccess、readme.txt 和文件夹:app、cake、plugins、vendors)...

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)...

首先,我在 Apache 中设置了一个别名 (test),指向E:/Projects/cakephp/",但它不起作用(消息:糟糕!此链接似乎已损坏.)

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.)

经过一番搜索,我发现我必须将别名设置为另一个文件夹:E:/Projects/cakephp/app/webroot/",它完美地运行并显示了第一页CakePHP 框架.

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.

我解决了第一页中的所有问题(使用 CakePHP 手册).我试图按照 CakePHP 博客教程...我做了一个模型、一个控制器和一个视图页面(都与帖子"主题相关),但是当我尝试查看结果时,我刚收到 WAMP 服务器的第一页(显示地址有问题)

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)

我使用的地址:"http://localhost/test/posts/index"(没有用)然后,我尝试将 index.php 放在 url 中: "http://localhost/test/index.php/posts/index" 并且成功了!

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 文件,当我尝试访问根目录 "http://localhost/test/》完美运行,不知道哪里出了问题!

.htaccess files when I try to reach the root "http://localhost/test/" work perfect, I don't know what's wrong!

xx 我在 StackOverflow 中发现了同样的问题,这里 .它的所有设置都与我的相似,只是他似乎将别名设置为 CakePHP 的根目录,但它对我不起作用!

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!

实际上我找不到如何使用该解决方案 (link) 对他有帮助,因为我认为这对我来说有点不同!

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!

我用于以下 cakephp 文件夹的 htaccess 文件如下,

My htaccess files for following cakephp folders are as following,

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!

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

呜呜呜!我找到了答案!我对所有的 htaccess 文件进行了许多更改!如果您也有此问题,请先删除所有更改,然后使用此 link 有很大帮助!也希望能帮到你!干杯!很多芝士!!:D

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

推荐答案

  1. 右键单击您的 WAMP 图标任务栏
  2. 然后将鼠标悬停在 Apache 模块上
  3. 向下滚动并确保 rewrite_module 被勾选

这篇关于如何在 WampServer 中配置 CakePHP 的 .htaccess 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆