Good day!) I can not figure out how to organize such a thing: the site content is divided into languages and cities. The question is how to convert a query like / Russian to? Lang = Russian and / Muhosransk to? Sity = Muhosransk while there are about a hundred languages and about 700 cities. And combined queries like / Russian / Muhosransk / =>? Lang = Russian & sity = Muhosransk are possible For each of them, to make a condition is somehow wasteful. Also, I would not like to make URLs like lang / Russian, sity / Muhosransk or l_Russian /, s_Muhosransk /. Well, all the more so to pull up the data from the database and redirect to php. Tell me, please, is it possible and if so, then at least push the thought)) Thank you all in advance!
2 answers
It will not work like this simply.
Either you will have to set a match for EACH URL, therefore it is better / lang / ru ->? Lang = ru, you can set the language anyway and better / city / Muhosransk ->? City = Muhosransk only in this case, you can translate this way.
either option number 2: do
RewriteEngine on RewriteRule ^(ru|en)/([a-z0-9\-/]+)?$ index.php?m=$2&lang=$1&%{QUERY_STRING} [PT,L] RewriteRule ^([a-z0-9\-/]+)?$ index.php?m=$1&%{QUERY_STRING} [PT,L]
If ru or en is encountered first, then ru en is output to? Lang, and everything that goes after them into the variable m ... all other processing is already on the php script side.
Probably in your case it will be the most optimal and painless.
- thunder, thank you very much) - markoffvv
- yes please) "accept" the answer if correct;) - thunder
The Mod Rewrite Generator can be used to turn dynamic URLs into search engine friendly static URLs. If you want to take a quick look at your URLs, you’ll be
It was answered here . And in a bunch of places before that. Try searching 99% of questions for 'mod_rewrite' by CNC.
- Thanks for the link, it will come in handy) - thunder