Project

General

Profile

[Solved] What is the difference between ${url.query} and ${qsa}

Added by timothy about 2 months ago

I was reading the wiki page on mod_rewrite mod_rewrite. It mentions ${url.query} and ${qsa} as two of the the substitute strings that can be used. Could someone explain to me what the difference are between these two?

Thank you.


Replies (5)

RE: What is the difference between ${url.query} and ${qsa} - Added by gstrauss about 2 months ago

The documentation says:

${url.query}
${qsa} appends query string, if not empty

${url.query} is the query string (without the '?') and you are responsible for '?' in the replacement URL, if that is why you want, or of using other encodings, if that is what you want.

${qsa} appends the query string if the query string is not empty (or "blank"). If some other query string already exists on the replacement URL, then lighttpd appends '&' and then the original query string, otherwise lighttpd appends '?' and then original query string.

RE: [Solved] What is the difference between ${url.query} and ${qsa} - Added by timothy about 2 months ago

I guess my confusion came from incorrectly assuming "if not empty" refers to the query string of the "source" not being empty, whereas in reality it was referring to query string of the "target" not being empty.

Thanks for the explanation, that was very helpful.

RE: [Solved] What is the difference between ${url.query} and ${qsa} - Added by gstrauss about 2 months ago

I guess my confusion came from incorrectly assuming "if not empty" refers to the query string of the "source" not being empty, whereas in reality it was referring to query string of the "target" not being empty.

It does refer to the source. ${qsa} will have no effect if the source query string is empty. lighttpd will not add a stray & or ? if ${qsa} is empty/blank

RE: [Solved] What is the difference between ${url.query} and ${qsa} - Added by timothy about 2 months ago

It does refer to the source.

I understand what you mean.

The problem is, if it is interpreted as referring to the source, then both ${url.query} and ${qsa} "appends query string if (the source has query string that is) not empty", which means that this difference that you concisely explained is undocumented. Yet from first sentence of your first reply, I get the impression that you intend to mean that the difference has in fact been documented but I wasn't able to comprehend.

To reconcile the two points above --- that the documentation is correct and that the difference between ${url.query} and ${qsa} has already been documented --- the sentence in the documentation has to be interpreted in a particular way:
- "appends" means appending the query string from the source to an existing query string of the target with &...;
- "not empty" refers to the query string of the target not empty.

Personally, I think the wiki page around ${url.query} and friends could be made a bit clearer.

In any case, I really appreciate your time.

RE: [Solved] What is the difference between ${url.query} and ${qsa} - Added by gstrauss about 2 months ago

The words in the doc are precise, but I agree that they are not as descriptive as they could be. I added some words to the doc.

I think some usage examples might be helpful.

BTW, ${qsa} follows Apache QSA to provide similar functionality for which ${url.query} was insufficient.

    (1-5/5)