How to block access to the .htaccess file on an Apache web server.

Posted: June 14, 2016. At: 12:17 PM. This was 2 years ago. Post ID: 9260
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

Blocking access to the .htaccess file on your Apache web server blocks access to the file by curious web users that want to see what directives are in it. The code below added to the .htaccess file will forbid all access to the .htaccess file by web users while still allowing it to function.

#Deny attempts to view the Htaccess file.
<Files .htaccess>
Order allow,deny
Deny from all

Very important to add this code when setting up your web server.

No comments have been made. Use this form to start the conversation :)

Leave a Reply