2012-04-03 84 views
0

我想不通,为什么下面不工作阿帕奇ModRewrite模式没有存储

RewriteCond ${foobar:test:$1}^
RewriteRule ^/?(.*)$ /check.php?url=$1 [L] 

foobar是一个程序(简单的bash脚本),并从内它,我写入文件,看看有什么输入是。 check.php是一个简单的php脚本,它显示GET的内容。这里是我所得到的,当我通过正则表达式($1)同时将shell脚本和PHP脚本:

url       check.php    foobar 

www.example.com/index.html index.html   test: 
www.example.com/index.php index.php    test: 
www.example.com/test.html test.html    test: 

基本上,图案的重写规则内的认可,而不是参数foobar的。

注意:shell脚本没有任何问题。相反,如果我把它像这样${foobar:test:abc123}输出为“test:abc123

回答

1

从我的角度来看:

RewriteCond ${foobar:test:$1}^

第一$1是无感,因为$1应参考以前表达式,如:

RewriteRule ^/?(.*)$ /check.php?url=$1 [L] 

所以我不明白这是如何工作的,如果有工程,这是...奇怪。

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap

也许是这样的:

RewriteRule ^(.*)$ ${foobar:test:$1} [R,L,NC] 

可以工作。