首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的模式重写规则不能在APACHE2 2/Debian/VirtualMin下工作

为什么我的模式重写规则不能在APACHE2 2/Debian/VirtualMin下工作
EN

Stack Overflow用户
提问于 2011-01-15 05:15:57
回答 3查看 3.8K关注 0票数 0

在使用CodeIgniter开发了许多站点之后,我通常会包含一个.htaccess文件来删除URL的“index.php”组件。

以前从没出过问题。

我的新网站使用我的“标准”.htaccess文件

.htaccess

代码语言:javascript
复制
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|uploads)
RewriteRule ^(.*)$ /index.php/$1 [L]

重写规则应该接受不以“index.php”或“uploads”开头的任何请求,并将其附加到“index.php”的末尾--例如:

1:http://mysite.com/controller -> http://mysite.com/index.php/controller

2:http://mysite.com/anothercontroller -> http://mysite.com/index.php/anothercontroller

它在我的开发服务器(MAMP)上正常工作,但是,我试图使用: Apache2将其上传到服务器上,该服务器由Debian上的VirtualMin控制虚拟主机。

mod_rewrite已在此服务器上启动并运行,因为简单的规则工作如下:

代码语言:javascript
复制
RewriteRule ^old.html$ new.html

apache错误日志似乎没有显示出任何不合适的地方。

对于为什么在apache2 2/debian/ VirtualMin服务器上不能工作,有什么想法(或者如何使用VirtualMin为虚拟主机打开重写日志,这样我就可以进一步分析)。

干杯:)

编辑I设法找出如何提高VirtualMin中调试的错误级别--这是输出--看起来我得到了递归.?

代码语言:javascript
复制
[Sat Jan 15 09:11:52 2011] [error] [client 110.174.208.166] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Sat Jan 15 09:11:52 2011] [debug] core.c(3063): [client 110.174.208.166] r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /index.php/
[Sat Jan 15 09:11:52 2011] [debug] core.c(3069): [client 110.174.208.166] redirected from r->uri = /
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-01-17 07:55:53

好的..。那么多小时后,我找到了我的解决方案。

首先,我想向自己证明那不是Debian,所以我

  • 在我拥有的备用VPS上新安装了一份最低限度的Debian副本
  • 安装Apache2
  • 启用重写模块和允许重写
  • 复制.htaccess文件和php文件
  • 普雷斯托!没什么问题!!

好吧--所以不是Debian + Apache --然后我在Apache下的VPS上设置了虚拟主机--仍然工作得很好。

回到VirtualMin + Apache + Debian

  • 备份虚拟主机.conf文件
  • 跨工作Debian + Apache虚拟主机文件复制
  • 普雷斯托!啊,真灵。

好的..。因此,这与VirtualMin‘编写’虚拟主机.conf文件的方式有关。

仔细地逐个注释掉文件,我发现了<Directory /home/example-domain/public_html>部分下面的冒犯行:

代码语言:javascript
复制
       AddHandler fcgid-script .php
       AddHandler fcgid-script .php5
       FCGIWrapper /home/epeau/fcgi-bin/php5.fcgi .php
       FCGIWrapper /home/epeau/fcgi-bin/php5.fcgi .php5

注释掉这四行,一切都如愿以偿。由于某些原因,使用FastCGI似乎会导致问题。

票数 0
EN

Stack Overflow用户

发布于 2011-01-15 22:01:22

Virtualmin配置标准Apache。在Virtualmin系统上重写规则与任何其他Apache配置没有什么不同。Virtualmin系统中的web服务器是Apache。所以,不要为您的问题寻找"Virtualmin解决方案“;这个问题与Virtualmin无关(虽然Virtualmin确实有一些UI工具来编辑和修改htaccess文件和重写规则等等,但是您不需要使用它们,而且它们与您在htaccess文件中手动执行的操作没有任何神奇或不同之处)。

比较您在开发系统上的实际httpd.conf与您的生产system...something是不同的。您的操作系统更有可能是默认配置差异的根源。

例如,检查以确保htaccess允许您尝试使用的所有指令。可以限制htaccess文件可以配置的功能,我怀疑Debian默认配置在默认情况下比MAMP严格得多。您可能会在所讨论的虚拟主机的error.log中看到一些错误,或者在主error.log中看到一些错误。

票数 1
EN

Stack Overflow用户

发布于 2011-01-16 00:16:10

你考虑过使用FallbackResource吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4698154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档