我有一个Apache 2.2的VirtualHost其中DocumentRoot指向/var/www/mysite.com目录。 我也有Alias ,使一些位于/var/www/stuff页面/脚本很容易获得(给别人VirtualHosts):
<VirtualHost *:80> DocumentRoot /var/www/mysite.com ServerName www.mysite.com <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/mysite.com/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> Alias /stuff /var/www/stuff </VirtualHost>
DocumentRoot目录包含阻止未经/var/www/mysite.com/.htaccessvalidation的访问的.htaccess文件( /var/www/mysite.com/.htaccess ):
AuthType Basic AuthName "Please say the word..." AuthBasicProvider file AuthUserFile /var/www/mysite.com/.htpasswd AuthGroupFile /dev/null Require valide-user
当我尝试访问http://www.mysite.com时 ,我得到了HTTP身份validation表单。 当我尝试访问http://www.mysite.com/stuff时 ,我没有得到HTTP身份validation表单:文件可以自由访问。
看起来/var/www/mysite.com/.htaccess在访问http://www.mysite.com/stuff时被跳过,因为文件在/var/www/stuff id中。 不在/var/www/mysite.com/.htaccess的父目录下。
我发现唯一的解决方法是创build一个/var/www/stuff/.htaccess符号链接到/var/www/default/.htaccess :
user@server:~$ ln -s /var/www/default/.htaccess /var/www/stuff/.htaccess
有没有更好的/更清洁的解决scheme?
如果/ var / www / stuff实际上是/var/www/mysite.com/stuff,并且您删除了别名,它将按照您的要求工作。 就目前而言,“东西”不在DocumentRoot内部,为什么地球上的Apache会在.htaccess文件的其他地方完全查找?