[英]Apache RewriteMap with URL's that may or may not contain a query string
我們有一個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]
但是,它似乎沒有任何作用。 我究竟做錯了什么?
試一下
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]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.