get user country by ip

Discuss server installationa nd configuration issues here

Moderators: macek, egami, gesf

faust
New php-forum User
New php-forum User
Posts: 109
Joined: Thu May 03, 2012 7:22 am

get user country by ip

Postby faust » Sat May 05, 2012 4:07 am

I don't know if this is the right place to ask. If it's not, please move it whereever it shoud be. So, my problem: I have a website and I redirect it with .htaccess (ex. user types: domain.com and automatically redirects him to www.domain.com/en/). I use the following commands:

Code: Select all

RewriteCond %{HTTP_HOST} ^dev.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ http://dev.domain.com/bg/ [R=301,L]
RewriteRule ^(.*)/$ /index.php?lang=$1


So, basically my questions are:
1. Am I doing it right? (I don't know much about apache and config);
2. Is there a way to get the user ip, check if it's from outside my country and redirect him, for example, to dev.domain.com/en/ ?
3. Is there a way to put the lang (/bg/.../en/) parameter in all urls and links in the site, because I have a lot of ajax and redirects and functions and it'll be a real pain in the ass if I have to rewrite all the links and new function parameters?
Just for example, I have dev.domain.com/en/product/{PRODUCT_CODE}/{PRODUCT_TITLE}. I also have dev.domain.com/en/article/{ARTICLE_CODE}/{ARTICLE_TITLE}. These links are all over my site and in some places I use ajax, some don't...

Any help would be highly appreciated. If you need more info, tell me. Thanks.

Return to “Server installation and configuration”

Who is online

Users browsing this forum: No registered users and 1 guest

cron