如何在Apache Web服务器中启用.htaccess

时间:2019-05-19 01:25:58  来源:igfitidea点击:

问题:-如何为Apache web服务器启用.htaccess ?
如何为Apache虚拟主机启用.htaccess ?
如何启用.htaccess使用httpd服务器?
htaccess启用了Apache服务器的目录级配置。
这允许用户覆盖Apache全局和虚拟主机设置。

在Apache中启用.htaccess

编辑Apache虚拟主机配置文件,并添加以下目录标记。

<VirtualHost *:80>
	ServerName example.com

	# Disable .htaccess for /var/www directory for security
	<Directory "/var/www">
		Allowoverride none
	</Directory>

	# Enable .htaccess for /var/www/html directory and its subdirectories
	<Directory "/var/www/html">
		Allowoverride all
	</Directory>
</VirtualHost>

第一个目录标签将禁止在/var/www目录中使用.htaccess。
第二个目录标签将允许在/var/www/html目录下使用.htaccess。