mod_rewrite不适用于特定目录

时间:2009-10-05 21:16:31

标签: .htaccess mod-rewrite

这让我完全厌倦了几天,我相信一旦我解决它就会显得很愚蠢,但如果我现在不求助,我会变得愚蠢。

我的mod_rewrite在我的localhost上成功运行(不涉及vhosts;这是我的笔记本电脑,我的开发机器),我在各种目录中使用.htaccess来帮助重写crufty 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了十几次。我甚至我想也许我有两个不同的Apaches在运行,但是没有,我只有一个,一个在/ usr / local / apache2下,我自己安装了一段时间。

1 个答案:

答案 0 :(得分:0)

在这里你所代表的一切都有一个外在的因素,这种情况令人困惑;具体而言,类似Alias或其他会导致/two请求转到~punkish/Sites/two以外的地方。