2012-12-07 131 views
0

我有这样的配置在虚拟主机:国防部重写长度

RewriteEngine On 
RewriteMap mapfile txt:mapfile.txt 
RewriteCond ${mapfile:$1?%{QUERY_STRING}} >"" 
RewriteRule ^/(.+)$ ${mapfile:$1?%{QUERY_STRING}}? [R=301] 

该工程确定这个mapfile.txt

prueba/code.asp?id=489 /newurl 

但有了这个mapfile.txt不匹配:

prueba/code.asp?id=489/

重写日志中:

[07/Dec/2012:20:52:08 +0100] [rid#7f1ac2d4280/initial] (5) map lookup OK: map=mapfile[txt] key=prueba/code.asp?id=489 -> val=/ 

[07/Dec/2012:20:52:08 +0100] [rid#7f1ac2d4280/initial] (4) RewriteCond: input='/' pattern='>""' => not-matched 

为什么不匹配?是否有另一种方法来测试查询长度是否大于“”

回答

0

它不匹配,因为它正在做你正在要求它做的事情,而不是你期望它做的事情。地图查找工作按预期产生有效:

RewriteCond/>"" 

然而,COND匹配字符串的操作装置“的字母排序顺序比较”和>“”可能会有问题。为什么不使用正则表达式。如果它包含(至少)一个字符,则会匹配:

RewriteCond ${mapfile:$1?%{QUERY_STRING}} . 
+0

非常感谢。现在这工作完美 – Luis