Protect Htaccess Files in WordPress Website

How to Protect Htaccess Files in WordPress Website

in Security
Google+ LinkedIn

As you already know, the HTAccess file is a very powerful tool for manipulating site performance and functionality. It also allows you to control files and folders in the current directory, and all sub-directories. That is why it’s very critical for your website security to protect HTAccess files of your website from any unauthorized access.

Earlier we have seen how to protect wp-config.php file and .svn Folders with the help of HTAccess. Now in this article we will show you how you can protect HTAccess files.

Fortunately, preventing access to your HTAccess files is relatively very easy. The following snippet will stop hackers from accessing your HTAccess files. You can, of course, still edit the file yourself via FTP client and through your hosting control panel’s file manager. Just paste this snippet in your HTAccess File.

# protect .htaccess files
<Files .htaccess>
    Order Allow,Deny
    Deny from all

It’s important to remember that you should always keep a backup of current working version of your HTAccess file before you begin editing. Because even if you are cautious, accidents can happen, and you would not believe how frequently they do. And in case of any error or misconfiguration in HTAccess file can usually cause your whole website to go down. So keep a backup.

Share the love

If you like this snippet, share it with others!

Leave a Reply

Your email address will not be published. Required fields are marked *