Forum Moderators: phranque

Message Too Old, No Replies

Understanding the QSA Flag

         

RhinoFish

7:53 pm on Sep 15, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




System: The following 2 messages were cut out of thread at: https://www.webmasterworld.com/webmaster/4963886.htm [webmasterworld.com] by not2easy - 5:58 pm on Sep 15, 2019 (atl -4)


are you guys saying that [QSA] is only needed if I have hard-coded a query string in to the RewriteRule?

Phranque is saying that.
I am NOT saying that.
:-)

that does not apply to the OP's problem statement which included these directives (with no query string in the Target of the RewriteRule):

I agree, the OP did not bring up incoming appended data pairs, but I sure did.
And I am saying it is very relevant to the discussion, though Phranque you do definitely disagree.

One small step at a time now...

Phranque, before the OP made any changes, if somebody were to visit this URL:
www.example.com
Would they be redirected to this URL?
www.example.com/foo/bar/

And Phranque, before the OP made any changes, if somebody were to visit this URL:
www.example.com/blog002.html
Would they be redirected to this URL?
www.example.com/foo/bar/blog002.html

lucy24

8:55 pm on Sep 15, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Would they be redirected to
No, because OP's question is not about an external redirect (message sent back to the browser instructing it to make a fresh request). It is about an internal rewrite--in this case via a [P] proxy, meaning that the rewrite involves a different host, but in all other respects behaving exactly the same as a “vanilla” rewrite.

If you mean “Would they be served content from”, say so. It’s an entirely different question.

RhinoFish

11:04 pm on Sep 15, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Whether external redirect or internal rewrite, the content that is served in either case would often include tracking scripts, like a Google Analytics traffic tracking script.

If the person visiting www.example.com arrives via:
www.example.com/?utm_source=google&utm_medium=cpc&utm_campaign=drivesales
Will these appended data pairs be passed to the content page served that would process these parameters (by sending info to Google Analytics), if QSA is not used?

lucy24

12:16 am on Sep 16, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Will these appended data pairs be passed to the content page served that would process these parameters
In mod_rewrite, any existing query strings are reappended by default. The only time a query string (containing any number of parameters) is lost through mod_rewrite activity, is if both of these conditions apply:

#1 the target of a RewriteRule includes a fresh query (including the null query, final ? question mark)
AND
#2 the RewriteRule does not include the QSA flag

When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
....
When the requested URI contains a query string, and the target URI does not, the default behavior of RewriteRule is to copy that query string to the target URI. Using the [QSD] flag causes the query string to be discarded.

Horse's mouth [httpd.apache.org] helpfully adds that if the writer of a RewriteRule experiences a momentary brain fart and applies both the QSA and the QSD flags--which would contradict each other--the QSD takes precedence. (They do not put it in exactly those terms, but that seems the likeliest scenario.)

RhinoFish

3:35 pm on Sep 16, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Exactly correct! Thanks! :-)