The previous article wrote to use the Apache GeoIP module to implement the sub-directory of domain name jump, he is the global effective, but my virtual host has other virtual host, if according to the previous article configuration, those do not need to do two level jump site will not be able to access the normal. The following configuration is only valid for sites that require a sub-directory jump: The only way to do this is to change the virtual host configuration file that needs to be jumped.
Cd/etc/httpd/conf.d
Vim cn-en.conf
#NameVirtualHost *<VirtualHost *:80>DocumentRoot /var/www/html/ServerName Www.ruizengguoji.comloadmodule geoip_module modules/mod_geoip.so<ifmodule mod_geoip.c> geoipenable ongeoipdbfile /usr/share/geoip/geoip.datrewriteengine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CN$ RewriteCond %{HTTP_HOST} ^www.a.com [NC] RewriteRule ^/$ /cn/index.html [R=301,L]RewriteEngine on rewritecond %{env:geoip_country_code} ^ (CA| us| MX) $&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;REWRITECOND&NBSP;%{HTTP_HOST}&NBSP;^WWW.A.COM&NBSP;[NC] rewriterule ^/$ /en/index.html [r=301,l]</ Ifmodule></virtualhost>
If there are other sites in my web hosting directory, it will not be affected by the above two sites.
To test whether other sites are available:
Cd/etc/httpd/conf.d
Vim bbs.conf
#NameVirtualHost *<virtualhost *:80>documentroot/var/www/html/bbsservername bbs.a.com</virtualhost>
Echo BBS >/var/www/html/bbs/index.html
In the browser test OK passes.
This article is from the "david0512" blog, make sure to keep this source http://gjr0512.blog.51cto.com/6518687/1749956
Virtual host-based Apache GeoIP settings