You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rich Bowen <rb...@rcbowen.com> on 2009/12/27 22:20:05 UTC

mod_rewrite patch

A FAQ on the various httpd support channels is "how do I make the  
query string go away". The answer is that you put "?" on the end of  
the target URL, which is a bit of a kludge.

Attached is a patch that adds a QSD (qsdiscard) flag that does this a  
little more elegantly. As with my previous email, I wanted some review  
first before adding Yet Another Rewrite Flag.

I'm also aware that a patch of this kind was submitted a couple years  
back and ignored, but I wasn't able to find it in the archives.


Re: mod_rewrite patch

Posted by André Malo <nd...@perlig.de>.
* Rich Bowen wrote:

> A FAQ on the various httpd support channels is "how do I make the
> query string go away". The answer is that you put "?" on the end of
> the target URL, which is a bit of a kludge.

-1 from the peanut gallery. I think, using an empty query string ("?") is 
not such a kludge and doesn't justify yet another flag. Maybe just 
documenting the issue better would help.

But this opinion is not very strong. Another bit of mod_rewrite overload 
doesn't do that much harm, either ;-)

nd
-- 
"Solides und umfangreiches Buch"
                                          -- aus einer Rezension

<http://pub.perlig.de/books.html#apache2>

Re: mod_rewrite patch

Posted by Eric Covener <co...@gmail.com>.
2009/12/28 Rich Bowen <rb...@rcbowen.com>:

> This slightly revised patch has the effect described above. That is, the
> original QS is discarded, but any QS on the target is added on - which would
> have been the effect if you hadn't used QSD at all.

Just like half of the uses of QSA in the wild, where there's no
explicit query string in the substitution.

-- 
Eric Covener
covener@gmail.com

Re: mod_rewrite patch

Posted by Rich Bowen <rb...@rcbowen.com>.
On Dec 28, 2009, at 05:51 , Vincent Bray wrote:

>>
>> Another point came up while thinking about it: Next time you'll  
>> have to
>> explain that
>>
>> RewriteRule foo bar?x=y [QSD]
>>
>> conflicts and QSD wins (as I read the patch(es)). Dunno if that has  
>> to be
>> done in an apologetic manner, though ;-)
>
> That's a good point. I'd prefer to see the query string preserved in
> that case. So, QSD only has an effect if the rule contains no query
> string.


This slightly revised patch has the effect described above. That is,  
the original QS is discarded, but any QS on the target is added on -  
which would have been the effect if you hadn't used QSD at all. Note  
also that if you use QSA and QSD at the same time, QSD wins, and the  
replacement query string is used by itself, rather than appended to  
the original query string. Here again, it's far from clear what  
someone would expect, when using both flags.


Re: mod_rewrite patch

Posted by Vincent Bray <no...@gmail.com>.
2009/12/28 André Malo <nd...@perlig.de>:
>> Yes please! While the null query string hack works, it is an ugly hack
>> to have to foist on people. I've had to suggest it in an apologetic
>> manner too many times.
>
> Another point came up while thinking about it: Next time you'll have to
> explain that
>
> RewriteRule foo bar?x=y [QSD]
>
> conflicts and QSD wins (as I read the patch(es)). Dunno if that has to be
> done in an apologetic manner, though ;-)

That's a good point. I'd prefer to see the query string preserved in
that case. So, QSD only has an effect if the rule contains no query
string.

Another point is that removing the query string isn't just cosmetic
but can have an effect on cacheability.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.9

-- 
noodl

Re: mod_rewrite patch

Posted by Rich Bowen <rb...@rcbowen.com>.
On Dec 28, 2009, at 05:45 , André Malo wrote:

> Another point came up while thinking about it: Next time you'll have  
> to
> explain that
>
> RewriteRule foo bar?x=y [QSD]
>
> conflicts and QSD wins (as I read the patch(es)). Dunno if that has  
> to be
> done in an apologetic manner, though ;-)

On the one hand, if you REPLACE the query string like this, then the  
original query string is removed already, without using the QSD flag.  
It's not at all clear what they had in mind when using that flag with  
a replacement query string. What were they trying to accomplish? The  
solution is, "don't do that".

On the other hand, in my testing, that rule did in fact sort of work,  
with the new query string being stuck on, but escaped, which isn't  
what I expected. That is, I ended up at bar%3fx=y

I'll have to look at this a little closer ...

--
Rich Bowen
rbowen@rcbowen.com




Re: mod_rewrite patch

Posted by André Malo <nd...@perlig.de>.
* Vincent Bray wrote:

> 2009/12/27 Rich Bowen <rb...@rcbowen.com>:
> > A FAQ on the various httpd support channels is "how do I make the query
> > string go away". The answer is that you put "?" on the end of the
> > target URL, which is a bit of a kludge.
> >
> > Attached is a patch that adds a QSD (qsdiscard) flag that does this a
> > little more elegantly. As with my previous email, I wanted some review
> > first before adding Yet Another Rewrite Flag.
>
> Yes please! While the null query string hack works, it is an ugly hack
> to have to foist on people. I've had to suggest it in an apologetic
> manner too many times.

Another point came up while thinking about it: Next time you'll have to 
explain that

RewriteRule foo bar?x=y [QSD]

conflicts and QSD wins (as I read the patch(es)). Dunno if that has to be 
done in an apologetic manner, though ;-)

However, maybe that's the reason it wasn't a flag in the first place.

nd
-- 
die (eval q-qq[Just Another Perl Hacker
]
;-)
# André Malo, <http://pub.perlig.de/> #

Re: mod_rewrite patch

Posted by Vincent Bray <no...@gmail.com>.
2009/12/27 Rich Bowen <rb...@rcbowen.com>:
> A FAQ on the various httpd support channels is "how do I make the query
> string go away". The answer is that you put "?" on the end of the target
> URL, which is a bit of a kludge.
>
> Attached is a patch that adds a QSD (qsdiscard) flag that does this a little
> more elegantly. As with my previous email, I wanted some review first before
> adding Yet Another Rewrite Flag.

Yes please! While the null query string hack works, it is an ugly hack
to have to foist on people. I've had to suggest it in an apologetic
manner too many times.

> I'm also aware that a patch of this kind was submitted a couple years back
> and ignored, but I wasn't able to find it in the archives.

Here it is: http://markmail.org/message/utxqiujml7firkdy

-- 
noodl