HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


htaccess language detection

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#71627 (In Topic #15066)
Avatar

Well-settled

Strict Default Language Code

Hello everyone, it's been a while since I've been here.

This is an off topic ocPortal conversation about a function of htaccess with language detection.

I have been working on a website for an organization. I'm using WordPress.

The organization is Israeli and the default language is Hebrew. I've made the website both in Hebrew and English.

English is in the root.
Hebrew is in /he/.

I'm using this code in the .htaccess:

Code

#The 'Accept-Language' header starts with 'he'#and the test is case-insensitive ([NC])RewriteCond %{HTTP:Accept-Language} ^he [NC]RewriteRule ^$ /he/ [L,R=301]RewriteCond %{HTTP:Accept-Language} ^iw [NC]RewriteRule ^$ /he/ [L,R=301]  #For every other language - EnglishRewriteRule ^$ [L,R=301]

This code works well. The problem with this code is…

In English, I can go to the Hebrew side, look at it normally. Everything is fine.
In Hebrew, I can go through the Hebrew side like normal, everything is fine. But when I try to get to the English side, it takes me right back to Hebrew.

Is this because my English is in the root directory? If I moved this to a directory called /en/ would this help? Any ideas how to fix this or work around it?
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: