这让我完全困惑了好几天,我相信一旦我解决了它,我会显得很愚蠢,但如果我现在不寻求帮助,我会变得更愚蠢。
我已经在本地主机上成功地完成了mod_rewrite(没有vhost参与;这是我的笔记本电脑,我的开发机器),我在不同的目录中使用.htaccess来帮助重写粗糙的URL,使之干净。除了它不能在一个目录中工作。因为在这个问题上不可能复制我的整个笔记本电脑,所以我提供以下细节。
在我的httpd.conf中,我加载了mod_rewrite.so。
LoadModule rewrite_module modules/mod_rewrite.so
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>
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]
**更新:**任何地方都没有涉及别名。这是我的笔记本电脑,所有东西都在上面提到的文档根目录下,所以我只需访问每个目录即可
http://localhost/
. 是的,拼写错误是一个很大的可能性(我确实说过,一旦我解决了它,我会看起来很愚蠢,但是,现在,我在任何地方都没有发现一个拼写错误,是的,我已经重新启动Apache大约十几次了)。我甚至认为可能我有两个不同的Apache在运行,但没有,我只有一个,在/usr/local/apache2下,我不久前自己安装了它。