[wp-hackers] Making different home URL

Abdussamad Abdurrazzaq abdussamad at abdussamad.com
Wed Mar 16 13:38:13 UTC 2016


Hi,

Install mod_geoip for apache. It'll use the free geoip database from 
maxmind. This is assuming you have root access to the server. After this 
is installed you can just refer to $_SERVER['GEOIP_COUNTRY_NAME'] and 
$_SERVER['GEOIP_COUNTRY_CODE'] to redirect people using PHP. .htaccess 
level redirects are also possible and are infact better than doing it in 
PHP. I think something like this will do it in .htaccess

rewritecond %{GEOIP_COUNTRY_CODE} =de
rewritecond %{HTTP_HOST} !^de.example.com
RewriteRule ^(.*)$ http://de.example.com/$1 [R=301,L]

If you don't have server level access then look up geoip lite apis from 
maxmind. They offer a PHP SDK too. The database is called geoip lite 
country. You can then make a plugin that does the redirect based on the 
geoip mapping.

Regards,
Abdussamad

On 03/16/2016 05:35 PM, pushpendu mondal wrote:
> Hi,
>
> But how can I detect the IP from where anyone is viewing, I mean how can I
> change my home url dynamically with respect to country.
>
> Thanks
>
> On Wed, Mar 16, 2016 at 6:01 PM, Frank Bueltge <frank at bueltge.de> wrote:
>
>> If you have also different content, language for each key "de" etc. then
>> think about a solution via WP Multisite, each site for each language key.
>> You can also create relationship between objects, like post, page,
>> taxonomy, then can help the plugin MultilingualPress or custom source.
>>
>> Best.
>>
>> Liebe Grüße
>> Frank
>> Ⓦ WordPress solution architect
>> __
>> http://bueltge.de
>> http://inpsyde.com
>> http://multilingualpress.pro
>> http://marketpress.com
>>
>> Privat: +49 36428 169305 | Mobil: +49 170 5322053
>>
>> Inpsyde GmbH, http://inpsyde.com, Mutzer Heide 3, 51467 Bergisch Gladbach
>> Steuernr: 204/5756/0999, Steueridentnr.: DE263849534
>> Geschäftsführender Gesellschafter: Heinz Rohé, HRB 65224, Amtsgericht Köln
>>
>> On Wed, Mar 16, 2016 at 1:28 PM, Joel Mandell <joelmandell at gmail.com>
>> wrote:
>>
>>> I think you can use
>>>
>>> <link rel="alternate" type="text/html" hreflang="de" href="/de/" />
>>>
>>> And do that for every language.
>>> Think it should be sufficient.
>>> Den 16 mar 2016 13:23 skrev "pushpendu mondal" <
>>> pushpendu.mondal at delgence.com>:
>>>
>>>> Hi,
>>>>
>>>> Guys, I came across a problem and I require some help.
>>>> The problem is that I want to have different Home_Url with respect to
>> IP
>>> or
>>>> the location where anyone belong.
>>>>
>>>> for example:
>>>>   If I stays in United States, I want to have my Home_Url like*
>>>> https://www.example.com/ <https://www.example.com/>* so when  anyone
>>> tries
>>>> to open my site he should be redirected to above link.
>>>>
>>>> If I stay in Germany , I want to have my Home_Url like*
>>>> https://www.example.com/de <https://www.example.com/de>* so when
>> anyone
>>>> tries to open my site he should be redirected to this link.
>>>>
>>>> How can I achieve this, Is there any way or any plugin?
>>>>
>>>> Thanks
>>>>
>>>> --
>>>> *Pushpendu Mondal* (Senior WordPress Developer)
>>>> *T :* +91 33 66155181
>>>> *M :* +91 9614648464 *Netherlands: Delgence B.V*
>>>> Liessentstraat 9a, 5405 AH Uden The Netherlands. *W :*
>> www.delgence.com
>>>> *E :* pushpendu.mondal at delgence.com <prushpendu.Mondal at delgence.com>
>>>> *INDIA*
>>>> Rishi Tech Park New Town,
>>>> Rajarhat ,WB,
>>>> Kol.700156. *USA: Delgence LLC*
>>>> 675 Ocean Avenue. Unit 2F Long Branch, NJ-07740
>>>> USA
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>


More information about the wp-hackers mailing list