开发者

Rewriting query URL

开发者 https://www.devze.com 2023-04-12 15:23 出处:网络
Suppose I have URLs with query string parameters like these: index.php?lag=en&name=About Us&itemid=60

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 ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号