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


1

我正在尝试从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是要走的路吗?

Answers:


1

是的,这THE_REQUEST是一种解决方法,因为它将包含具有以下规定的整个http请求:

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

我看了一下文档,但是我将其解释为意味着REQUEST_URI将包含GET参数。那好吧。
ripper234 2011年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.