我们有RewriteMap
,其中包含以下示例:
/home /
/index?q=video /videos
/index?q=media /media
/epic.html /epic
我们如何RewriteMap
匹配可能有或可能没有附加QUERYSTRING的网址?
我们目前正在使用:
RewriteMap mappings txt:/data/redirect_mappings
RewriteCond ${mappings:$1|Unknown} !Unknown
RewriteRule ^(.*)$ ${mappings:$1?%{QUERY_STRING}|$1?%{QUERY_STRING}} [L,R=301,QSD]
但是,似乎没有任何效果。我做错了什么?
答案 0 :(得分:0)
试一试
RewriteMap mappings txt:/data/redirect_mappings
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} (.*)
RewriteCond ${mappings:%1|NOTFOUND} !NOTFOUND
RewriteRule ^(.*)$ ${mappings:%1}? [L,R=301]
RewriteCond ${mappings:$1|NOTFOUND} !NOTFOUND
RewriteRule ^(.*)$ ${mappings:$1} [L,R=301]