Need a new rule
1 post
• Page 1 of 1
Need a new rule
Hi
I need to create a rewrite rule for a multi language app where the language is stored in the URL. For example:
http://[domain]/[langcode]/default.asp
should redirect to:
http://[domain]/default.asp?lang=[langcode]
This should work for any subdirectories so for example:
http://[domain]/[langcode]/path/to/directory/somefile.asp?par=val
should redirect to:
http://[domain]/path/to/directory/somefile.asp?par=val&lang=[langcode]
I need a single rule to work for multiple levels of subdirectory and in addition, I need the rule (or a 2nd rule) to also handle any number of parameters.
Basically, whatever the URL I need to extract the language code from the URL and append it as an additional parameter on the URL.
I saw the following rule:
RewriteRule /(\w+)/([^?]*)(\?.*)? http\://www.domain.com/$2?3$3&lang=$1:\?lang=$1 [I,RP]
However I am having 2 issues with this rule.
1. It doesnt seem to work on ssl pages (https)
2. If a user doesnt not type in a language it should just default as no language supplied.
So for example I have the following:
RewriteRule ^[^?/]*-(\d+)$ item.asp?pid=$1 [NC,L,QSA]
which would produce smth like this
http://www.xyz.com/item.asp?pid=233 ---> http://www.xyz.com/bla-bla-bla-233
Now I need to add languages so if a user enters
http://[domain]/bla-bla-bla-233 (this shows in english - or no langunge in the querystring would essesntially just look like http://[domain]/item.asp?pid=233&lan=)
However if a user enters http://[domain]/br/bla-bla-bla-233 it would direct someone to http://[domain]/item.asp?pid=233&lan=br
Ideally I have multiple URL rewrites already so i would add one last rule to my file to check for
http://[domain]/(language)/
if it is found always append it to the querystring as such "lan=whateverlangauge"
Can anybody suggest how this can be made possible?
Thanks
I need to create a rewrite rule for a multi language app where the language is stored in the URL. For example:
http://[domain]/[langcode]/default.asp
should redirect to:
http://[domain]/default.asp?lang=[langcode]
This should work for any subdirectories so for example:
http://[domain]/[langcode]/path/to/directory/somefile.asp?par=val
should redirect to:
http://[domain]/path/to/directory/somefile.asp?par=val&lang=[langcode]
I need a single rule to work for multiple levels of subdirectory and in addition, I need the rule (or a 2nd rule) to also handle any number of parameters.
Basically, whatever the URL I need to extract the language code from the URL and append it as an additional parameter on the URL.
I saw the following rule:
RewriteRule /(\w+)/([^?]*)(\?.*)? http\://www.domain.com/$2?3$3&lang=$1:\?lang=$1 [I,RP]
However I am having 2 issues with this rule.
1. It doesnt seem to work on ssl pages (https)
2. If a user doesnt not type in a language it should just default as no language supplied.
So for example I have the following:
RewriteRule ^[^?/]*-(\d+)$ item.asp?pid=$1 [NC,L,QSA]
which would produce smth like this
http://www.xyz.com/item.asp?pid=233 ---> http://www.xyz.com/bla-bla-bla-233
Now I need to add languages so if a user enters
http://[domain]/bla-bla-bla-233 (this shows in english - or no langunge in the querystring would essesntially just look like http://[domain]/item.asp?pid=233&lan=)
However if a user enters http://[domain]/br/bla-bla-bla-233 it would direct someone to http://[domain]/item.asp?pid=233&lan=br
Ideally I have multiple URL rewrites already so i would add one last rule to my file to check for
http://[domain]/(language)/
if it is found always append it to the querystring as such "lan=whateverlangauge"
Can anybody suggest how this can be made possible?
Thanks
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests