3

我正在使用 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.

另外,如果我输入 URL127.0.0.1localhost,我会用“示例”虚拟主机定义我的项目......这非常令人困惑,有人可以帮忙吗?

4

1 回答 1

0

听起来您的根目录和子目录 htaccess 文件有冲突。从根 htaccess 文件中排除子目录处理,并确保使用[L]ast 规则指令。

根 HTACCESS - 排除“test”子目录,使用[L]ast 规则指令。

Options +FollowSymLinks

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(js|gif|jpeg|jpg|png)$

# exclude the "test" subdirectory
RewriteCond %{REQUEST_URI} !^(test)/?

# add [L]
RewriteRule . index.php [L]

“测试”子目录 HTACCESS - 使用[L]ast 规则指令。

RewriteEngine on
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(js|gif|jpeg|jpg|png)$

# add [L]
RewriteRule . index.php [L]
于 2013-12-30T19:37:39.847 回答