byzantine cucumber
byzantine cucumber

Reputation: 531

how do i use .htaccess to redirect different languages to different pages?

I'm trying to make a simple 2-language site, en and th, I am unfamiliar with .htaccess but found an online tool: http://www.htaccesstools.com/redirection-by-language/

I would like English browsers to go to my root folder's index.html, and Thai browsers to a subfolder.

What I got from the generator is:

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} th [NC]
RewriteRule .* http://www.mysite.com/th/index.html [R,L]

This doesn't work and I get a redirect loop/other error. I've tried changing the url on the last line to be relative, but this doesn't affect it.

Any help?

*to confirm, i have one .htaccess in my root folder only

Upvotes: 2

Views: 1034

Answers (1)

anubhava
anubhava

Reputation: 784958

Try this in your .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(/th/index.html|.*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ [NC]
RewriteCond %{HTTP:Accept-Language} ^th [NC]
RewriteRule .* /th/index.html [R,L,QSA,NE]

Upvotes: 1

Related Questions