Protect WordPress Configuration wp-config.php File Using Htaccess

Protect WordPress configuration wp-config.php file

WordPress security has always been a concern and most of the users are still figuring this out. Have you ever thought to protect WordPress configuration wp-config.php file?

This is one of the most important files present in the WordPress directory which has all the authentication keys and connects your database with the rest of your website.

The wp-config.php file is responsible for handling many special aspects of your website. You may in need to edit the wp-config.php file for many reasons.

Protecting this file would be a plus point. In this post, you will learn the easiest way to block everyone to access this file using the .htaccess file.

Stop the Access to wp-config.php File Using a Simple Code

Most of the time, people fret a lot because of such technical things. I must tell you that to run a successful WordPress blog, you should learn these basic techie aspects.

You need to edit the .htaccess file. Do you know how and where is it present?

There are two different ways. If you’re using the Yoast SEO plugin you can just have to go to SEO>>Advanced and you will see “File Editor”.

protect wp-config.php file

It will take you to a new page where you can easily see the robots.txt and .htaccess files.

But if you’re using any other SEO plugin then you can use the cPanel of your web hosting account.

Go to cPanel>>file manager>>.htaccess file. Don’t forget to check the box to show the hidden files because the dot signifies that it’s a hidden file.

Add this code and save.

#protect wp-config.php
<Files wp-config.php>
order allow,deny
deny from all
</Files>

This code will block the access to this file by everyone else than you. No one would able to add any extra code having an intention to break your website.

Millions of websites get hacked every year and it’s important to protect the wp-config.php file. It’s recommended by the official WordPress website.

There are a few WordPress security plugins which can help you with this. You can use an option to enable the protection for the files like XML, .htaccess, wp-config.php etc.

You would also be interested in knowing about more WordPress security tips. You can protect your WordPress admin login panel using many tricks.

Hackers find the vulnerabilities to the websites and inject the malicious code. Wouldn’t that be the worst if your website gets hacked?

Well, never give a chance to anyone and add every possible security layer you can.

I hope You Can Easily Protect WordPress Configuration wp-config.php File

As I have mentioned earlier, it’s not hard as it seems. If you’re afraid of editing then it’s recommended to use the plugin like Yoast SEO.

Most of the people are using it for better SEO score of their websites. But the file editing using the cPanel method is the method for everyone.

Is it hard to edit the files present in the WordPress directory? Can you protect WordPress configuration wp-config.php file? If you have any doubt, feel free to clear it.

You can also connect with us on Twitter, LinkedIn, and Facebook.

by Ravi Chahar

A WordPress Professional and a LinkedIn Influencer. A coder by passion and a blogger by choice. WordPress theme development is his forte. He is your WordPress guy who will teach you how to solve WordPress errors, WordPress security issues, theme development, design issues and what not.

Leave a Reply

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