Rewriting query URL
Suppose I have URLs with query string parameters like these:
index.php?lag=en&name=About Us&itemid=60
index.php?host=consumer&lag=en&name=About Us&am开发者_StackOverflowp;itemid=64
Using mod_rewrite, how can I redirect them like these?
en_About Us_60.php
consumer/en_About Us_64.php
In the Above urls values are dynamic.
Something like this:
RewriteEngine on
RewriteCond %{QUERY_STRING} host=(.*)&lag=(.*)&name=(.*)&itemid=(.*)
RewriteRule ^index.php(.*)$ /%1/%2_%3_%4 [QSA]
RewriteCond %{QUERY_STRING} lag=(.*)&name=(.*)&itemid=(.*)
RewriteRule ^index.php(.*)$ /%1_%2_%3 [QSA]
Remember, to check all the statements, which are possible ;)
精彩评论