In configuring location match
rules for OpenBSD httpd, which uses patterns, an OpenBSD implementation of Lua patterns, the following rules result in any request that begins with one of the characters (l
,i
,orb
) to be URL 404 due to not being processed by the second rule. (This is to support rewrites for DokuWiki URL Rewriting).
The following two rules are part of the configuration that I suspect are the problem:
location match "/(lib/.*)" {
request rewrite "/%1"
}
location match "/([^lib])" {
request rewrite "/doku.php?id=$DOCUMENT_URI&$QUERY_STRING"
}
(Note thatL
, I
, or B
produce the desired output.)
I have tried changing the sets, but I am just guessing and I think that the concept I am missing is to understand how to make a rule where only lib
is interpreted for the first rule (I think this is already correct) and everything not lib
is interpreted for the second rule (which I think is the problem rule since the problem persists even when the first rule is commented).
The solution is to use a completely different second rule:
location "/*" {
request rewrite "/doku.php?id=$DOCUMENT_URI&$QUERY_STRING"
}
Since httpd
evaluates rules sequentially and uses the first matching rule, the match for everything that is not lib/
will pass the first rule, so it doesn't need to be considered when creating the second rule.