Need a country-based filtering for legal restrictions or to improve security?
xCountryBlacklist is a MODX extension to redirect users connections coming from specific countries.
This extra check user countries using the iplocate.io to geolocate countries from IPs.
Installation
Download and install xCountryBlacklist
Dependency: ipCountryRedirect extra (required, will be automatically installed if not installed).
Snippet properties
Add the folllowing property settings with the default countries of your choice and redirection ID:
Snippet options
Option | Values | Default / Notes |
---|---|---|
iso | example: dz,af,us | ISO alpha-2 country code list |
redir | example: 1 | Redirection resource ID |
You can search for ISO alpha-2 country codes here.
Examples
[[!xCountryBlacklist]]
With this example default property settings are used.
[[!xCountryBlacklist?
&iso=`dz,af,ma,tn,ae,sa`
&redir=`198`
]]
With these options connections coming from Algeria, Afghanistan, Morocco, Tunisia, United Arab Emirates, Saudi Arabia will be redirected to resource ID 198.
How to test it?
To check redirection for the specified countries, you can use a country-based proxy browser extension or use a proxy location corresponding to one of the specified countries.