我已经使用MAMP和Ubuntu服务器多年,但最近尝试在Mac OS X 10.7.5上使用内置的Apache服务器。 我的问题是我的一些.htaccess文件正在阅读,有些则没有。 我有2个网站,这里是他们的虚拟主机设置:
<VirtualHost *:80> ServerName site1.rob DocumentRoot /Users/username/Sites/localSites/site1/public/ <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName site2.rob DocumentRoot /Users/username/Documents/Dropbox/site2/public/ <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
网站1工作,因为它应该,但网站2没有。 所以我跑了一个testing。 在每个.htaccess文件中,我做了一个环境检查。
SetEnv HTACCESS on
然后,我用这个检查在根中创build了一个PHP文件。
var_dump($_SERVER['HTACCESS']);
我的站点1的输出是: string(2) "on"
我的站点2的输出是: null
在这两个网站,如果我只是去/index.php他们正常工作。 任何线索我可以做什么从这里排除故障? 文件权限?
我似乎无意中偶然发现了答案。 我在/ etc / apache2 /的不同文件夹中查找,发现有一个名为users的目录。 在我的用户名中有一个.conf文件。 在那里它只有一个AllowOverride设置为None。 这个conf文件一定是覆盖了虚拟主机。 我把它设置为全部,现在似乎工作正常。