Category Archives: security

Allowing or Blocking based on Country with .htaccess

Examples
Redirection with mod_geoip and mod_rewrite
Below are examples of how to perform redirection based on country with mod_geoip and mod_rewrite. This configuration should be added to your Apache httpd.conf or .htaccess file.

GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

# Redirect one country
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$
RewriteRule ^(.*)$ http://www.canada.com$1 [L]

# Redirect multiple countries to a single page
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$
RewriteRule ^(.*)$ http://www.northamerica.com$1 [L]

List of .htaccess Examples

From the .htaccess cheatsheet

Hardening WordPress with .htaccess

AskApache WordPress Hardening Plugin
Filed Under (Plugin Reviews, WordPress) by DK on 7 August 2008

BlogSecurity released a popular article last year titled “Hardening WordPress with htaccess”. It provided basic, yet effective techniques to harden a WordPress blog install.
Using Apache’s mod_rewrite allows us to perform basic filtering and application firewalling. AskApache is pushing mod_rewrite boundaries to [...]