Thursday, March 01, 2012

Apache

How to redirect your website base on country ip request, Apache, geoip, rewrite

Install the mod-geoip

sudo apt-get install libapache2-mod-geoip

Enable the mods:

sudo a2enmod rewrite
sudo a2enmod geoip

In your file ".htaccess" add these lines:

# if country is PT
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^PT$
RewriteRule ^(.*)$ http://www.site.pt

# else
RewriteEngine on
RewriteRule ^(.*)$ http://www.site/en/

You have to configure the virtual host to read the .htaccess file.
<directory /var/www/site/>
 Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</directory>


In your file "httpd.conf" add these lines:


GeoIPEnable On
GeoIPDBFile /usr/local/share/geoip/geoip.dat



Download the file from http://www.maxmind.com/app/geolitecountry and put it in /usr/local/share/geoip/geoip.dat

There are a lot of versions. This one is free for countries :)




Using mod_spdy With Apache2 On Ubuntu 12.04
from: http://www.howtoforge.com/using-mod_spdy-with-apache2-on-ubuntu-12.04

SPDY runs over HTTPS, so we need an HTTPS-enabled web site to test SPDY. Please note that SPDY will fall back to HTTPS if the user's browser does not support SPDY or if things go wrong, so installing mod_spdy doesn't hurt your existing setup.

a2enmod ssl
a2ensite default-ssl
/etc/init.d/apache2 restart

cd /tmp
wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_amd64.deb
dpkg -i mod-spdy-*.deb
apt-get -f install
/etc/init.d/apache2 restart
chrome://net-internals/#spdy
Post a Comment

bootstrap_fonts_woff: inputs: - '%kernel.root_dir%/../vendor/twitter/bootstrap/fonts/glyphicons-halflings-regular.woff' output...