[英]Apache ModRewrite pattern not stored
I can't figure out why the below doesn't work我不明白为什么下面不起作用
RewriteCond ${foobar:test:$1} ^
RewriteRule ^/?(.*)$ /check.php?url=$1 [L]
foobar
is a program (simple bash script) and from within it I am writing to file to see what the input is. foobar 是一个程序(简单的
foobar
脚本),我在其中写入文件以查看输入是什么。 check.php
is a simple php script which displays the contents of GET
. check.php
是一个简单的 php 脚本,它显示GET
的内容。 Here is what I get when I pass the regular expression ( $1
) to both the shell script and the php script:这是我将正则表达式 (
$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:
basically, the pattern is recognized within the RewriteRule, but not the parameter to foobar.基本上,模式在 RewriteRule 中被识别,但不是 foobar 的参数。
Note: there is nothing wrong with the shell script.注意:shell脚本没有问题。 If instead I call it like so
${foobar:test:abc123}
the output is " test:abc123
"相反,如果我这样称呼它
${foobar:test:abc123}
output 是“ test:abc123
”
From my point of view:在我看来,我的观点是:
RewriteCond ${foobar:test:$1} ^
the first $1
is a non-sense because $1
should refer to a previous expression, like:第一个
$1
是无意义的,因为$1
应该引用前面的表达式,例如:
RewriteRule ^/?(.*)$ /check.php?url=$1 [L]
So I don't get how this could work, and if something works, it's... strange.所以我不明白这是如何工作的,如果有什么工作,那就......很奇怪。
See http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap参见http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap
Maybe something like:也许是这样的:
RewriteRule ^(.*)$ ${foobar:test:$1} [R,L,NC]
Could work.可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.