Re: Unclear RewriteCond docs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-05-08 09:33, Eric Covener wrote:
On Mon, May 8, 2023 at 10:29 AM Daniel Gruno <humbedooh@xxxxxxxxxx> wrote:

On 2023-05-08 08:44, Eric Covener wrote:
On Mon, May 8, 2023 at 9:41 AM Frank Gingras <thumbs@xxxxxxxxxx> wrote:

Sebb,

Are you sure about that? I would verify before we venture to clarify the docs.

I think sebb is right, I've occasionally had to try to weirdly
propagate it or delay/combine it.

In a rule or condition, the captures of the preceding condition is available

Only if the next condition is a regex condition. A literal string
comparison condition will not reset the previous captures. And yeah, you
can use the teststring value to add back your captures from the previous
condition:

# Get key value into %1
RewriteCond %{QUERY_STRING} "key=(.+)"
# Append query string with %1, get key value back into %1, bar value into %2
RewriteCond %1::%{QUERY_STRING} "^(.+)::.*bar=(.+)"
# Literal comparison, doesn't change backrefs:
RewriteCond %2 ="foo"
RewriteRule .* http://foo.bar/%1/%2

Ah, cool and tricky to document in an "intro".  Maybe we can make sure
the gory details are right elsewhere, and caution that it's more
complicated with multiple conditions in the intro example.

Yeah, you can actually use this to accept and parse query string key/value pairs given in an arbitrary order, but as you say, it gets complex real fast - I am having to resort to making RewriteCond macros to accomplish this without having to write 200 lines of config :)

We do have a page dedicated to advanced usage examples, maybe I can add something to that page.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux