0
votes

I have main site created in wordpress on domain mysite.com (multi language site).

By default mysite.com opens in local language not english. I have registered local domain to be redirected to mysite.com.

mysite.local -> mysite.com (this is fine)

But I want to redirect mysite.com to mysite.com/en for international users. If they type address mysite.com in browser or open from google I want the user to be redirected to /en version of the page.

Is it possible to achieve this with apache .htaccess, because I have shared hosting with htaccess only?

1
“By default mysite.com opens in local language not english.” - meaning, you have something that automatically redirects to the preferred language indicated by the browser? Then we’d need to know the details of how that was implemented. - CBroe
@CBroe mysite.com is built in Wordpress with WPML plugin and default language in WPML settings is set to local (russian) language. For international users, there is /en/ site. - Janiis
Then you probably need a combination of a RewriteCond that checks that the requested URI did not start with any of your potential language identifiers, and a RewriteRule that simply inserts the en/ portion at the beginning of the path and redirects there. - CBroe
@CBroe I think, I will write Wordpress plugin for that. - Janiis

1 Answers

0
votes

You can achieve this which the following .htaccess rules -

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/en/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /en/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ en/index.html [L]