[英]DirectorySlash Off doesn't work
我正在使用Apache 2.4.7
这是我的虚拟主机的配置:
DocumentRoot /var/www/login
ServerName login.mydomain.com
<Directory "/var/www/login">
allow from all
AllowOverride All
Options +Indexes
DirectoryIndex index.html index.php
DirectorySlash Off
Require all granted
</Directory>
在我的/var/www/login
目录中,我有一个名为freeseat
目录,并且在其中有index.php
文件,因此它的完整位置是/var/www/login/freeseat/index.php
当我尝试通过以下链接(已替换域)访问它时,它将重定向到相同的URL,并带有斜杠: http : //login.mydomain.com/freeseat- > http://login.mydomain.com/freeseat /
为什么DirectorySlash Off
无法正常工作? 我试图将其放在.htaccess
,但这也无济于事。
非常感谢你的帮助,
大卫
首先,如果不使用指令,您的vHost将无法工作。 这有效:
<VirtualHost *:80>
DocumentRoot /var/www/login
ServerName login.mydomain.com
<Directory "/var/www/login">
Allow from all
AllowOverride All
Options +Indexes
DirectoryIndex index.html index.php
DirectorySlash Off
Require all granted
</Directory>
ErrorLog /var/www/login/error.log
</VirtualHost>
回答您的问题:DirectorySlash可以正常工作。
另请参阅有关mod_dir的 apache文档,尤其是“ DirectorySlash”部分中名为“安全警告”的红色框。
提示:始终使用不可公开访问的错误日志来确定邪恶的根源。 :)
编辑#1:
我想我可能误解了您的问题。 您想通过http://login.mydomain.com/freeseat (不带斜杠)访问/var/www/login/freeseat/index.php
。
然后,删除freeseat文件夹,并将index.php用作var / www / login / freeseat.php,并在/var/www/login/.htaccess文件中创建RewriteRule(必须激活mod_rewrite):
RewriteEngine On
RewriteRule ^freeseat$ freeseat.php
另外,放下
Options +Indexes
DirectoryIndex index.html index.php
从您的vHost配置。 不再需要了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.