【发布时间】:2011-06-28 06:21:16
【问题描述】:
我需要重定向简化版:
/search.html?param1=val1¶m2=val2¶m3=val3&location=UK
收件人:
/search/United-Kingdom/arg4=val2&arg5=val1
参数可以是任意顺序或缺失,位置是地图文件中扩展的代码(英国、英国等)。
如果没有匹配的参数重定向到:
/search-info/
当前位置扩展代码:
RewriteMap location_map txt:/path/to/locations_map.txt
RewriteCond %{REQUEST_URI} .*search.html.* [NC]
RewriteCond %{QUERY_STRING} .*location=([^&]+).* [NC]
RewriteCond ${location_map:%1} ^(.*)$
RewriteRule ^(.*)$ /search/%1/ [R=301]
如何换掉参数名称并丢弃不需要的参数(即上面的 param3)?
【问题讨论】:
标签: regex apache url mod-rewrite configuration