Virtual host-based Apache GeoIP settings

Source: Internet
Author: User
Tags geoip web hosting

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.