【发布时间】:2012-11-03 22:31:06
【问题描述】:
我使用的是 Windows 7 64 位(也许这并不重要)并且我安装了 xampp。 在我的 htdocs/ 目录中,我有多个项目。现在,对于其中一个(比如说 htdocs/test/),我创建了一个名为“example”的虚拟主机。而且效果很好... 在 dir /test/ 我有 .htaccess 文件,其中包含以下代码:
RewriteEngine on
RewriteBase /test
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(js|gif|jpeg|jpg|png)$
RewriteRule . index.php
在这里,我想将所有流量重定向到我的index.php 页面,因为我在这里使用我的一些系统来处理从索引页面开始的整个项目。在httpd.conf 中,我启用了rewrite_module 和内部
<Directory "C:/Program Files/xampp/htdocs">
我已将 AllowOverride 指令更改为 All。
现在,正如我所说,当我尝试使用创建的虚拟主机“示例”访问我的项目时,这可以正常工作。但是当我尝试访问我的 htdocs 目录中的其他项目时,我得到一个内部服务器错误 (HTTP 500) 和日志文件中的这条消息:
[Thu Nov 15 11:07:12 2012] [error] [client 127.0.0.1] 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.
另外,如果我输入 URL 127.0.0.1 或 localhost,我的项目会使用“示例”虚拟主机定义...
这非常令人困惑,有人可以帮忙吗?
【问题讨论】:
-
如果您有 Apache 2.2,将 LogLevel 设置为调试将无济于事。要开始了解它,您需要在 vhost
指令中添加这些指令: RewriteLog "logs/myvhost.rewrite.log" RewriteLogLevel 1; rewriteloglevel 告诉 apache 详细程度,从 0(无)到 9(所有)。根据需要更改 myvhost.rewrite.log。 -
虚拟主机的 DocumentRoot 是哪个目录?
-
请您为
test和另一个项目提供您的虚拟主机配置? -
尝试将
[L]指令添加到您的RewriteRule以停止处理。听起来链接您的根目录和子目录 htaccess 文件有冲突,可能从您的根目录重写中排除子目录。
标签: apache .htaccess mod-rewrite xampp localhost