apache的AllowOverride,如果none则.htaccess不生效,如果为all,则网站的图片和文件都不能访问

apache的AllowOverride,如果none则.htaccess不生效,如果为all,则网站的图片和文件都不能访问,都是403,请问如何又让.htaccess生效,又能不影响网站文件的访问

你可以设置none,然后下面配置一个文件块,让.htaccess生效,例如:

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Files ".ht*">
    Require all granted
# 默认为 Require all denied
</Files>
# <Files>的工作方式类似于<Directory>块,但是应用于单个文件。在默认情况下,它阻止httpd提供敏感文件,如.htaccess和.htpasswd