htaccess rules for languages

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
moonoo
Forum Members
Forum Members
Posts: 77
Joined: Fri Jan 08, 2010 12:23 am
Location: Wales - UK

htaccess rules for languages

Post 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.
Peciura

Re: htaccess rules for languages

Post 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.
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

[The extension txt has been deactivated and can no longer be displayed.]

Last edited by Peciura on Wed Mar 31, 2010 2:55 am, edited 1 time in total.
moonoo
Forum Members
Forum Members
Posts: 77
Joined: Fri Jan 08, 2010 12:23 am
Location: Wales - UK

Re: htaccess rules for languages

Post 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?
Peciura

Re: htaccess rules for languages

Post 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.
moonoo
Forum Members
Forum Members
Posts: 77
Joined: Fri Jan 08, 2010 12:23 am
Location: Wales - UK

Re: htaccess rules for languages

Post 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?
User avatar
requish
Forum Members
Forum Members
Posts: 183
Joined: Sat Jan 24, 2009 3:12 pm

Re: htaccess rules for languages

Post 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.
Last edited by requish on Tue Apr 20, 2010 6:52 pm, edited 1 time in total.
CMS Made Simple! Best CMS! :)
Peciura

Re: htaccess rules for languages

Post 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.
User avatar
requish
Forum Members
Forum Members
Posts: 183
Joined: Sat Jan 24, 2009 3:12 pm

Re: htaccess rules for languages

Post by requish »

Peciura wrote: 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.
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?
Last edited by requish on Wed Apr 21, 2010 7:14 pm, edited 1 time in total.
CMS Made Simple! Best CMS! :)
Locked

Return to “[locked] CMSMS MLE fork”