Reputation: 11
I need to redirect my store customers to another clone installation in a sub-directory.
For Example: A US visitor can visit: ‘example.com/product’ When a Canadian visitor visits the same link, it should redirect to: ‘example.com/ca/product’
I have tried out a few geo redirection plugins but the issue is as follows: The redirection goes to ‘example.com/ca’ and the ‘product’ part is left out.
Any fixes?
NOTE: I have a clone installation of ‘example.com’ on ‘example.com/ca’.
Upvotes: 1
Views: 3067
Reputation: 11
You should use the plugin WPML for multilanguge. With this plugin you can use the option redirect by language WPML > Languages > Redirection according to browser language. I have it set up like this in a website of mine and it works fine.
If you want do it trought IP, you will need to add some more work. Im sending you info, I hope it is useful for you:
https://wpml.org/forums/topic/autoselect-native-language/#post-284007
https://wpml.org/forums/topic/how-to-detect-ip-location-and-automatically-display-local-language/
Upvotes: 1
Reputation: 426
I didn't need such a comprehensive multilingual plugin setup in my wordpress installation. So I have just used multi-site and added this to my htaccess file to redirect users to my 'irish' site based upon browser language config:
RewriteCond %{HTTP:Accept-Language} ^ie [NC]
RewriteCond %{REQUEST_URI} !ie [NC]
RewriteRule ^(.*)$ https://yoursite.com/ie [L,R=301]
I hope this is a quick and easy fix for someone. As I tried doing an action in functions.php and kept going around in circles for an hour!
Upvotes: 2