Blocking web access by country code via htaccess

Some Ukraine and Russian folks don’t know how to behave so I decided to block the whole country. Also¬†they’re not target audience for the targeted web.

# .htaccess

<IfModule mod_geoip.c>
GeoIPEnable On
SetEnvIf GEOIP_COUNTRY_CODE UA blk
SetEnvIf GEOIP_COUNTRY_CODE RU blk
Deny from env=blk
</IfModule>

They were causing 509 Bandwidth Limit Exceeded on some client webs with Joomla :/

PHP error_reporting per directory with htaccess

Finally figured it out how to set custom error_reporting in specific directory without changing the global configuration, this prevents me from forgetting setting it back.
This is useful when I need to hack something in Joomla or other older CMS ūüėõ

Just add the following line into .htaccess:

php_value error_reporting 6135

For figuring out the suitable integer for your needs check http://stackoverflow.com/a/3758453/289404

Redirect images (other media) content to live production site

During some redesign projects it’s handy to have the images (other media) rendered, but sometimes it could be a struggle to download from specific paths.

For WordPress sites I use the following htaccess rule:

RedirectMatch 301 /wp-content/uploads/(.*)$ http://www.example.com/wp-content/uploads/$1

Than for other, custom stuff:
RedirectMatch 301 /media/(.*)$ http://www.example.com/media/$1