Hi. Can anyone tell me how to redirect visitors according to their country? What I want to do is; 1. Visitors from Malaysia(My country) will be redirect into subdomain where it is in Bahasa Melayu(Malaysian Language). 2. Visitors from outside Malaysia will remain on the main domain. What is the .htaccess code? And, if the visitors from Malaysia choose to view the page in English, they will not be redirected back into the subdomain. Thanks in advance...
.htaccess is apache file for multiple settings, redirection is just one of the options. If you know complete IP range for Malaysia set up a rewrite condition (if your server allows you to ... ) in htaccess to redirect tweaking code below RewriteEngine On RewriteBase / RewriteCond %{REMOTE_HOST} IP ADDRESS RewriteCond %{REQUEST_URI} /index\.html$ RewriteRule .* http://Malaysia.yoursite.com [R=301,L] Code (markup): HTH
Well, by IP? Then how to add several IP address in here? RewriteCond %{REMOTE_HOST} IP ADDRESS Code (markup): And my website is using generator. (Wordpress) How do I feel this? RewriteCond %{REQUEST_URI} /index\.html$ Code (markup):
create an index.html because index.html is have more priority then index.php then setup a javascript which can look on geoip location database then redirect it based by geoip database try search on google their is many of the source about this
If your site is hosted on a VPS or dedicated server and you can install software, install MaxMind's GeoIP database and mod_geoip. If you are on shared hosting you could ask them to install it. You would then do this replacing Canada's country code (CA) with Malaysia's: RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$ RewriteRule ^(.*)$ http://www.redirectedsite.com$1 [L]
this is the real answer i never know mod_geoip is available for apache 2.2 too ? and can i put more then 1 country ?
I have a slightly different issue. Using RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|UK)$ RewriteRule ^(.*)$ http://www.northamerica.com$1 [L] Code (markup): I can redirect visitors from Canada/US/UK to the site northamerica.com But for something different, I only want to allow visitors from Canada/US/UK on my site and redirect everyone else to northamerica.com. How should the reg exp be changed in the above rewrite rule to do this?
Try my ip2country php class, that uses Maxmind's geolite database with mysql importer. http://phpweby.com/software/ip2country