Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  DirectAdmin  >  How to Block Country Traffic in DirectAdmin?
Top Scroll

How to Block Country Traffic in DirectAdmin?

 2 min

Screening your audience to avoid any conflicts or complications becomes necessary to maintain a perfectly working website. As a DirectAdmin user, you can block the web traffic of a country on your hosting.

To Block Country Traffic

1. Log in to your DirectAdmin account.

2. Edit the .htaccess file via the File Manager tool.

Refer this article to know How to Create/Edit .htaccess File via DirectAdmin?

3. Enter this line at the end of the file:

<IfModule mod_geoip.c> RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$ RewriteRule ^(.*)$ – [F,L] </IfModule>

The given line has used the US, which is the country code for the United States of America. It will

You can refer to this link ISO 3166-1 alpha-2 to find the country codes you are looking for.

4. Click Save.

 

With it, the country traffic you choose to block will be screened by DirectAdmin. It means the server will reject any access request from the country you blocked.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.