Cyberattacks are touching a new high every other day. Further, the e-commerce sector is among the worst-hit sectors. And OpenCart stores are not doing any better. Besides, it is always recommended to be safe than sorry.
Now, you can take different approaches to protect your OpenCart store. Most of which are listed in this extensive OpenCart security guide here. One of the ways that we are going to discuss today is – OpenCart country blocking.
Blocking countries, where your store is not relevant is one of the most effective ways to cut down on –
- superfluous traffic, and
- server bandwidth expense.
For example, you are running an apparel business but you only deliver to limited countries. In such a case, restrict other countries that can access your OpenCart store.
Even if you run a global e-commerce store, blocking the notorious countries is only going to add to your business’ safety.
3 Approaches to Do OpenCart Country blocking
1. OpenCart Country Blocking With a Click
If you are not a very technical person then Astra Firewall is the right choice for you. Here is how you can use the Astra Firewall to block a country from accessing your OpenCart store:
- Log into your Astra dashboard.
- Go to the ‘Threats’ tab
- Navigate to the section that says ‘Add a custom rule’.
- Just type in the country you wish to block.
- Click on the ‘Block’ button and it’s done!
Astra Firewall also provides you an option to whitelist the countries. To whitelist countries from the Astra dashboard do the following:
- Log into your Astra dashboard.
- Go to the ‘Threats’ page.
- Navigate to the section that says ‘Add Custom Rule’.
- Just type in the country you wish to whitelist.
- Click on the ‘Trust’ button and it’s done!
2. OpenCart Country blocking via .htaccess
The .htaccess file is a very important file for your store configuration. OpenCart country blocking via .htaccess requires access to cPanel or FTP account in order to proceed with the following steps:
Step 1: Generate IP addresses of the countries you want to block.
- Visit https://www.countryipblocks.net/acl.php or any other site that generates a complete list of IP addresses of the country.
- Select the ‘country’ or the whole ‘continent’ that you want to block.
- Next from the list of formats, select ‘Apache .htaccess Deny’.
- After you are finished with the selections, click on ‘Create ACL’ button. The generated list will be used for country blocking in OpenCart.
Step 2: Embedding the content of generated list into .htaccess file
- The .htacces file can be accessed by navigating to public_html directory. This can be done by going through File Manager in cPanel or connecting to your account by File Transfer Protocol client.
- Once you are able to access the .htaccess file, the IPs from the list should be included in it.
- To include them simply select all, copy and into the .htaccess file.
- Save the file and you are done.
3. OpenCart Country Blocking via GeoIP Module
OpenCart GeoIP module helps you to block country or the whole continent from accessing your store. This module also provides you with an option either to redirect the blocked users to any other relevant link or display the custom message.
Vice-a-versa, it also allows you to whitelist the IP addresses of the users you want to allow access to your store. Using OpenCart GeoIP module you can simply block that country by following the steps below-
- Install the GeoIP extension.
- Navigate to Rule Information.
- Open Country List and select the countries or whole continent to block the access from visiting your website.
- Save the settings and you are done.
If you are an online store owner then there are a number of threats that can keep you awake at night. These threats can be DDoS attacks, website scraping, bad bots, and so on. So it becomes a necessity to protect your stores from such attacks for maintaining your brand reputation.
And knowing your target customers can really help to achieve this. It will allow you to block the users who are not relevant to your store based on location and help you minimize your footprint.
Lastly, let us know in the comments if you found the post helpful.