基于 Windows 的 apache 服务器 (wamp) 上的 cakephp 和 httpd.conf 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2330416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:49:53  来源:igfitidea点击:

cakephp & httpd.conf issues on windows based apache server (wamp)

mod-rewritecakephpwampapache

提问by GnrlBzik

So, i was wondering if some one could clarify following occurrence and maybe suggest how I could tackle this.

所以,我想知道是否有人可以澄清以下事件,并建议我如何解决这个问题。

sorry for the weird coloring of the code

抱歉代码的奇怪颜色

Let me explain the set up first. I have wamp server installed and it is located physically on one hd and then my development files are located on separate hd. So i have added alias to access specific dev folder

让我先解释一下设置。我安装了 wamp 服务器,它物理上位于一个硬盘上,然后我的开发文件位于不同的硬盘上。所以我添加了别名来访问特定的 dev 文件夹

in httpd.confi have following

在 httpd.conf我有以下

ServerRoot D:/Program Files/wamp/bin/apache/apache2.2.11  
Listen 80  
ServerName localhost:80  
DocumentRoot D:/Program Files/wamp/www  
<Directory />  
    Options FollowSymLinks  
    AllowOverride None  
    Order deny,allow  
    Deny from all  
</Directory>  
<Directory D:/Program Files/wamp/www/>  
    Options Indexes FollowSymLinks  
    AllowOverride all  
    Order Allow,Deny  
    Allow from all  
</Directory>  

following is in seperate conf file and included into httpd.conf

以下是单独的 conf 文件并包含在 httpd.conf 中

Alias /project_birthday_planner "E:/Development/--- Projects-Full/PROJECT - BirthdayPlanner/trunk/"  
<Directory E:/Development/--- Projects-Full/PROJECT - BirthdayPlanner/trunk/>  
    Options Indexes FollowSymlinks MultiViews  
    AllowOverride All  
    Order allow,deny  
    Allow from all  
</Directory>  

in my E:/Development/--- Projects-Full/PROJECT - BirthdayPlanner/trunk/i have my cakephp directories and files

在我的E:/Development/--- Projects-Full/PROJECT - BirthdayPlanner/trunk/我有我的 cakephp 目录和文件

here is the problem

这是问题所在

my mode rewrite is turned on and my htaccess files for following cakephp folders are as following,

我的模式重写已打开,我用于以下 cakephp 文件夹的 htaccess 文件如下,

root of the cakephp

cakephp的根

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

*\app*

*\应用程序*

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

*\app\webroot*

*\app\webroot*

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

when I access /project_birthday_planneri get following error 404 Not Found

当我访问/project_birthday_planner 时,出现以下错误404 Not Found

**Not Found**  
The requested URL /app/webroot/ was not found on this server.  

if i set DocumentRoot to my cakephp folder or move cakephp folders and files to initial DocucumentRoot folder, all fires up and works.

如果我将 DocumentRoot 设置为我的 cakephp 文件夹或将 cakephp 文件夹和文件移动到初始的 DocucumentRoot 文件夹,所有这些都会启动并工作。

question ishow do i tackle this issue, is this something that inherently comes with the use of apache Alias or am I missing some piece

问题是我如何解决这个问题,这是使用 apache Alias 固有的东西还是我遗漏了一些东西

should this set up be tackled via VirtualHost then?

那么这个设置应该通过 VirtualHost 解决吗?

thank you so much in advance

非常感谢你提前

采纳答案by Dark

You have to point the Rewritebase to the right path ... see here

您必须将 Rewritebase 指向正确的路径...请参阅此处