am trying to write a redirect but as a green noob is tougher than i tought. What i want is: on the condition that there are No Specific Page in the url, but the language IS set, it to redirect to the home page of that language. First ill tell you the nature of current working site and the apache code that achieves that:
/it/somepage goes nicely /somepage?ln=it
/de/somepage goes nicely /somepage?ln=de
/fr/somepage goes nicely /somepage?ln=fr
/cn/somepage goes nicely /somepage?ln=cn
# WORKS beautifully
RewriteRule ^zh-CN/(.*) /$1?ln=zh-CN [L]
RewriteRule ^cn/(.*) /$1?ln=zh-CN [L]
RewriteRule ^([a-z][a-z])/(.*) /$2?ln=$1 [L]
Here, the 3rd line is the default redirect. The ast and 2nd line make the exception for chinese language correcty go to /cn/somepage
HOWEVER
the above code gives error when the root is asked:
/it/ gives error 404
/it gives error 404
/de/ gives error 404
/de gives error 404
/xx should go to /xx/home?ln=xx
/xx/ should go to /xx/home?ln=xx
this is all on the condition that no /xx/certainpage is set, ofcourse! Thanks for any clues!
You need a rule like:
This also covers the case for URLs like
foo.com/cn
as well asfoo.com/cn/
. Place this as the last rule in the chain and it will used only if nothing else matches.