The following code will prevent user to access your .htaccess file. Also, you can block multiple file type as well.
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# prevent viewing of a specific file
<Files secretfile.jpg>
order allow,deny
deny from all
</Files>
# multiple file types
<FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
Order Allow,Deny
Deny from all
</FilesMatch>
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# prevent viewing of a specific file
<Files secretfile.jpg>
order allow,deny
deny from all
</Files>
# multiple file types
<FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
Order Allow,Deny
Deny from all
</FilesMatch>
Comment