Welcome to WebmasterWorld Guest from 3.231.226.211

Forum Moderators: Ocean10000 & phranque

Understanding the QSA Flag

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

Senior Member

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

joined:June 20, 2006
posts:2176
votes: 94



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
8:55 pm on Sept 15, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15934
votes: 888


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.
11:04 pm on Sept 15, 2019 (gmt 0)

Senior Member

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

joined:June 20, 2006
posts:2176
votes: 94


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?
12:16 am on Sept 16, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15934
votes: 888


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.)
3:35 pm on Sept 16, 2019 (gmt 0)

Senior Member

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

joined:June 20, 2006
posts:2176
votes: 94


Exactly correct! Thanks! :-)