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

Etisalat Payment Gateway Integration wordpress

Etisalat Payment Gateway Integration Wordpress What is Etisalat Payment Gateway? IPG (Etisalat Payment Gateway) is the only Payment Gateway in UAE offering electronic payment services especially in UAE and GCC countries. ... Etisalat Payment Gateway connects merchants (sellers of products) in a secure way with banks and financial institutions to process their transactions online. How do I pay my Etisalat bill online? Log on to www.etisalat.ae/quickpay to recharge your prepaid account easily, quickly and securely. Enter your mobile number, the amount, and pay using your credit or debit card. or you can integrate it to your website and receive payment via this gateway direct to you bank. How can I check my Etisalat offer? To check your balance: dial *121# To find prepaid offers and promotions: dial *101# To get Deal of the Day: dial *050# To transfer credit: type the command *100*mobile number*amount# and press ok. Etisalat Payment Gateway Integration wordpress ...

icici Payment Gateway for Joomla Magento OpenCart1.x-2.x OSCommerce PrestaShop WooCommerce Zencart wordpress

Download icici Payment Gateway for All types of CMS icici Payment Gateway for Drupal icici Payment Gateway for  Joomla icici Payment Gateway for  Magento icici Payment Gateway for  OpenCart (version 1.x) icici Payment Gateway for  OpenCart (version 2.x) icici Payment Gateway for  OSCommerce icici Payment Gateway for  PrestaShop icici Payment Gateway for  WooCommerce icici Payment Gateway for  Zencart Download the latest integration kits and shopping cart plugins for  icici Payment Gateway icici Payment Gateway for Joomla Magento OpenCart1.x-2.x OSCommerce PrestaShop WooCommerce Zencart wordpress   icici Payment Gateway  offers everything you need to accept payments online from your website. There are three ways you can integrate your website with our gateway. Hosted Payment Page Use our customisable hosted payment page. This is the fastest and simplest route to start accepting card payments through...

Etisalat Payment Gateway Integration Wix website

Etisalat Payment Gateway Integration with wix website The document provides the interface information to Integrate with Etisalat Payment Gateway to perform Ecommerce payment using REST (JSON). Please find the below transaction flow for implementing 3D secure eCommerce transactions. 1. The Registration API call should be triggered to payment gateway in which the ReturnPath property with Transaction details like amount, currency, OrderID etc. should be mentioned. 2. Redirect to Payment Portal URL, returned in Register call with TransactionID as hidden field. 3. Payer will proceed with 3D Secure Authentication process. 4. After 3D Authentication, control will returned back to Merchant’s ReturnPath property URL received in registration call. 5. Merchant sends Finalization API call to complete transaction.  import { fetch } from 'wix-fetch' ; // ... fetch ( "https://ipg.comtrust.ae/" , { "method" : "get" } ) ...