要解决Apache2在Ubuntu web服务器上拒绝访问除了提供的index.html之外的任何其他文件的权限问题,可以通过在Apache配置文件中进行设置来实现。
首先,确保你有root权限,然后打开Apache配置文件。
sudo nano /etc/apache2/apache2.conf
在文件中找到以下行:
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
将AllowOverride
设置为None
,这将禁用.htaccess文件:
AllowOverride None
接下来,找到以下行:
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
将AllowOverride
设置为None
,同样禁用.htaccess文件:
AllowOverride None
保存并关闭文件。
重启Apache服务器:
sudo service apache2 restart
现在,Apache2将仅允许访问提供的index.html文件,其他文件将被拒绝访问。