【发布时间】:2009-10-05 21:16:30
【问题描述】:
这已经让我彻底迷惑了几天,我相信一旦解决它我会看起来很愚蠢,但如果我现在不寻求帮助会更愚蠢。
我有 mod_rewrite 在我的 localhost 上成功运行(不涉及虚拟主机;这是我的笔记本电脑,我的开发机器),我在各种目录中使用 .htaccess 来帮助将粗糙的 URL 重写为清理 URL。除了...它在一个目录中不起作用。由于无法在此问题中重现我的整个笔记本电脑,因此我提供以下详细信息。
在我的 httpd.conf 中,我加载了 mod_rewrite.so。
LoadModule rewrite_module modules/mod_rewrite.so
在我的 httpd.conf 中,我包含了另一个类似这样的 conf 文件
Include /usr/local/apache2/conf/other/punkish.conf
在我的 punkish.conf 中,我有这样定义的目录
DocumentRoot "/Users/punkish/Sites"
<Directory "/Users/punkish/Sites">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/Users/punkish/Sites/one">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/Users/punkish/Sites/two">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
在 ~/Sites/one 我有以下 .htaccess 文件
RewriteEngine On
RewriteBase /one/
# If an actual file or directory is requested, serve directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise, pass everything through to the dispatcher
RewriteRule ^(.*)$ index.cgi/$1 [L,QSA]
而且,一切正常。但是,在我的目录中 ~/Sites/two 我有以下 .htaccess 文件
RewriteEngine On
RewriteBase /two/
# If an actual file or directory is requested, serve directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise, pass everything through to the dispatcher
RewriteRule ^(.*)$ index.cgi/$1 [L,QSA]
而且,没有任何效果。纳达。压缩。齐尔奇。我只是得到一个 404。我已经确定 mod_rewrite 甚至没有通过在其中放入虚假命令来查看我的 ~/Sites/two/.htaccess 并且除了 404 之外没有收到任何错误。
另一个令人困惑的问题——我在 httpd.conf 中使用 RewriteLogLevel 3 打开了 RewriteLog,但我的 rewrite_log 完全为空。我知道这很难解决,除非亲自坐在有问题的计算机前,但我希望有人能告诉我发生了什么。
**更新:** 没有任何地方涉及别名。这是我的笔记本电脑,一切都在上述文档根目录下,所以我只需以http://localhost/ 访问每个目录。是的,拼写错误的可能性很大(我确实说过一旦解决它我会看起来很愚蠢,但是,目前我还没有在任何地方发现一个拼写错误,是的,我现在已经重新启动了 Apache 大约十几次。我什至以为我可能有两个不同的 Apache 正在运行,但不,我只有一个,在 /usr/local/apache2 下的一个,我前一段时间自己安装了它。
【问题讨论】:
-
仔细检查verrrry是否有错别字——尤其是在目录名称中。另外,重新启动 apache :)
标签: .htaccess mod-rewrite