Page 1 of 1
htaccess rules for languages
Posted: Thu Mar 25, 2010 2:53 am
by moonoo
Is there scope to place the language part of the url at the end of the string using htaccess?
I want clean url's using htaccess and would like to use the lang as a session parameter instead of it being included in the url..
here is what I have at present:
RewriteRule ^(.*)/(.+)$ index.php?hl=$1&page=$2 [QSA]
Which produced a clean url lke so
http://www.mydomain.com/en/parent/child/child/
Is there a way of rewriting the url like this using htaccess so that it produces the below structure?
http://www.mydomain.com/parent/child/child/?hl=en or if no param is given it displays the default language anyway.
Look forward to hearing anyones thoughts on this.
Re: htaccess rules for languages
Posted: Wed Mar 31, 2010 1:24 am
by Peciura
Would it be OK if links looked llike ?
Code: Select all
/how-cmsms-works/pages-and-navigation/hl=en_US
EDIT: To have mixed url you have to edit at least one code file and .htaccess, so do backup first. Two files only guides what has to be done. If you don't know how to use them - better keep existing file and url configuration.
Re: htaccess rules for languages
Posted: Wed Apr 14, 2010 10:33 pm
by moonoo
I get an extra / in my url so it reads mydomain.com/parent/child/child//hl=en
Is there a way to get rid of this?
.htaccess has the starting folder as / wondering if this is the cause or not?
Re: htaccess rules for languages
Posted: Wed Apr 14, 2010 11:21 pm
by Peciura
I assume you changed code already and you know what that means.
If you want to go further - modify variable "$mletail", you know where.
Re: htaccess rules for languages
Posted: Sat Apr 17, 2010 5:41 pm
by moonoo
Hi there,
thanks for reply.. spoke to you on the IRC and discovered the reason for the above was that in the config my page type was a "/" so there was always an extra one at the end.. removed page extension and now url looks good!
As mentioned on IRC the Lang switch link reverts to the default method.. is there a way of targetting the $lang param as well so that when we switch from one language to the other the url structure is retained in the new way?
Re: htaccess rules for languages
Posted: Tue Apr 20, 2010 5:58 pm
by requish
hello.
I have website in two languages. I want to do load page with lang after the diagnosis of the user's browser language. htaccess should look like?
For example, a user of the Polish language the browser loads the page domena.pl / pl / index.html.
I have installed CMS MS 1.6.6 mle
OR:
How to implement in index.php code this solution?
http://forum.wpml.org/topic.php?id=415&page=2
Please help.
Re: htaccess rules for languages
Posted: Tue Apr 20, 2010 7:00 pm
by Peciura
Read this post to get the idea how language is set in CSMms-mle-fork.
http://forum.cmsmadesimple.org/index.ph ... #msg204700 .You can write function that checks user preference first and than overides other variables. Try in "/config.php" first.
Re: htaccess rules for languages
Posted: Tue Apr 20, 2010 7:09 pm
by requish
I am weak in programming. forgive me. where do I replace the line of code? I understand that I enter $_SERVER['HTTP_ACCEPT_LANGUAGE'], but where? how it should look like?
--
Anybody can help?