Skip to main content

How to protect or make more secure your wordpress website

How to protect or make more secure your wordpress website


As you read the title, you are probably wondering isn’t the wp-admin directory already password protected. You are required to login right. Well that is true, but to add an additional layer of security popular sites often add an extra layer of authentication. Few days ago, we started seeing some suspicious activity on WPBeginner, so our host HostGator advised us to password protect our WordPress admin directory. Apparently popular sites like Mashable do the same. In this article, we will show you a step by step guide on how to password protect your WordPress admin (wp-admin) directory.

To keep things easy and simple, we will only cover cPanel web hosting companies here just because cPanel has an easy enough interface to add password protected directories.

Login to your cPanel. Scroll down till you see the Security Tab. Click on the “Password Protect Directories” icon.

When you click on that, a lightbox popup will show up asking for directory location. Just click on web root. Once you are there, navigate to the folder where your WordPress is hosted. Then click on the /wp-admin/ folder. You will see a screen like this:


Simply check the box to password protect the directory. Then create a user for the directory. That is it. Now when you try to access your wp-admin directory, you should see an authentication required box like this:

Manual Method

First create a .htpasswds file. You can do so easily by using this generator. Upload this file outside your /public_html/ directory. A good path would be:

home/user/.htpasswds/public_html/wp-admin/passwd/

Then, create a .htaccess file and upload it in /wp-admin/ directory. Then add the following codes in there:

AuthName "Admins Only"
AuthUserFile /home/yourdirectory/.htpasswds/public_html/wp-admin/passwd
AuthGroupFile /dev/null
AuthType basic
require user putyourusernamehere

You must update your username in there. Also don’t forget to update the AuthUserFile location path.

I have a 404 Error or a Too many redirects error

Well this can happen depending on how your server is configured. To fix this issue, open your main WordPress .htaccess file and add the following code there before the WordPress rules start.
1
ErrorDocument 401 default
Well there you have it. Now you have double authentication for your WordPress admin area. This is a good alternative to limiting wp-admin access by IP address.
Update: Here is how to fix the Admin Ajax Issue
If you password protect your WordPress Admin directory, then it will break the Ajax functionality in the front-end (if it is being used). In our case, we don’t have any plugins that is using ajax in the front-end. But if you do, then here is how you fix that issue.
Open the .htaccess file located in your /wp-admin/ folder (This is NOT the main .htaccess file that we edited above).
In the wp-admin .htaccess file, paste the following code:
<Files admin-ajax.php>
    Order allow,deny
    Allow from all
    Satisfy any
</Files>

Comments

Popular posts from this blog

Dropshipzone Australia API Integration with WooCommerce: A Game-Changer for Online Retailers

  Introduction: The Power of Dropshipzone Australia API Integration with WooCommerce In the competitive world of e-commerce, efficiency and seamless operations are key to success. Dropshipzone Australia, a prominent player in the Australian online retail space, offers an API that integrates with WooCommerce, enabling store owners to automate and streamline their business processes. In this article, we’ll explore how leveraging Dropshipzone Australia API integration with WooCommerce can revolutionize your online store by simplifying product imports, inventory management, pricing strategies, and image optimization. Dropshipzone Australia API Integration with WooCommerce Why Dropshipzone Australia API Integration with WooCommerce Matters Managing an online store is no easy task. From keeping inventory up to date to ensuring that product details are accurate, store owners face numerous challenges daily. The Dropshipzone Australia API integration with WooCommerce addresses these pain...

Parasut Accounting & Invoicing integration with woocommerce

Parasut Accounting & Invoicing integration with woocommerce  Parasut is a cloud-based finance management application for Small Business Owners in Turkey. Please use Paraşüt mobile application alongside the web application to benefit from all features.  Paraşüt Accounting & Invoicing integration with woocommerce is useful for automation and fast process stop manual creating invoice will save time and efforts. Why e-Invoice with Parasut ? Manage your application processes with our e-invoice transition consultant.  Switch to e-invoice within 30 minutes* without leaving your seat. Parasut Accounting & Invoicing integration with woocommerce Use it at Affordable Prices Get rid of fees such as integration and training fees.  Send e-invoices with affordable e-top-up prices. Integrated Pre-Accounting When using e-document services with Paraşüt, manage your financial data from anywhere thanks to the features that will allow you to manage your preliminary accounting...

Batscrm api integration wordpress via custom form custom plugin

  BATS is the only software you need to automate, streamline, manage & grow your transportation business.  BATS takes performance to the next level with built-in features such as batch emails, inline editing and much more! Batscrm api integration wordpress via custom form custom plugin BATS gives you everything you need, upfront, to run your business more effectively while saving time and money in the process. Batscrm api integration wordpress via custom form custom plugin Why use Batscrm api integration wordpress AQua Pricing Engine Price your opportunities automatically or with the click of a button using our internally managed pricing engine eDoc - Electronic Signature BATS’ electronic signing platform allows you to capture signatures from customers as well as carriers, even if they’re not on Central Dispatch. Billing BATS’ powerful billing module captures & processes customers credit cards, manages commission payouts and manages all accounts receivables and payable...