如何访问mod_rewrite中的GET参数RewriteCond?

我试图从mod_rewrite访问GET参数。

例如,给定这个URL: http : //myserver.com/foo.png?foo=bar

以下规则不会捕获此URL:

RewriteCond %{REQUEST_URI} bar [NC] 

虽然这样做:

 RewriteCond %{THE_REQUEST} bar [NC] 

REQUEST_URI不包含GET参数吗? THE_REQUEST要走的路吗?

是的, THE_REQUEST是要走的路,因为它将包含整个http请求,并具有以下规定:

 THE_REQUEST The full HTTP request line sent by the browser to the server (eg, "GET /index.html HTTP/1.1"). This does not include any additional headers sent by the browser. 
  • mod_rewrite文档