开发者

Apache, LocationMatch: match query string

开发者 https://www.devze.com 2022-12-15 21:26 出处:网络
How can I match a query string using LocationMatch with apache? <LocationMatch \"/index.php\\?a=b.*\">

How can I match a query string using LocationMatch with apache?

<LocationMatch "/index.php\?a=b.*">
/开发者_如何学JAVA/ ...

... won't work unfortunately.


Looks like you can't include query strings in Location/LocationMatch.

From the Apache Docs:

For all origin (non-proxy) requests, the URL to be matched is a URL-path of the form /path/. No scheme, hostname, port, or query string may be included. For proxy requests, the URL to be matched is of the form scheme://servername/path, and you must include the prefix.


https://serverfault.com/questions/848320/can-locationmatch-regex-match-query-string-portion

Actually it's possible since Apache 2.4 (or less) using the tag as follow :

<LocationMatch "/test/upload.js">
        <If "%{QUERY_STRING} =~ /query=test/">
                ..
                'Your directives'
                ..
       </If>
</LocationMatch>

In this configuration directives will be applied only in the case the URL is under the form "/test/upload.js" and contains the query "query=test".

0

精彩评论

暂无评论...
验证码 换一张
取 消