You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Chris Schults <cs...@grist.org> on 2006/12/18 19:45:14 UTC

The case of the disappearing plus sign

We have a CGI script that will list all the stories tagged with a
specified keyword. For example, if you wanted to see all stories tagged
with "pollution":

/cgi-bin/script.pl?query=gristkeywords=pollution

For a more user-friendly URL, we setup the following rewrite rule in an
.htaccess file that is located in the directory "tag".

RewriteEngine on
RewriteRule ^([^/\.]+)?$ /cgi-bin/script.pl?query=gristkeywords=$1 [L]

This allows a user to use this instead: /tag/pollution

This is all working fine except when we use multiple keywords with "+"
as the separator, such as: /tag/water+pollution

It appears that the "+" is getting stripped out at some point as the
script is returning results for "water pollution" instead of
"water+pollution". Is it possible that Apache is the culprit or should
we be looking more closely at our script or rewrite rule?

Thanks,

Chris

--------------------------

Chris Schults
Web Production Manager
Grist Magazine
710 Second Avenue, Suite 860
Seattle, WA  98104
Phone: 206-876-2020, ext. 204
Fax: 253-423-6487
<http://www.grist.org>

To sign up for Grist by email, the world's top environmental news served
up with a sense of humor, click here <http://www.grist.org/signup/> or
send a blank email message to <da...@lists.grist.org> 

Re: The case of the disappearing plus sign

Posted by Robert Landrum <rl...@aol.net>.
Chris Schults wrote:
> It appears that the "+" is getting stripped out at some point as the
> script is returning results for "water pollution" instead of
> "water+pollution". Is it possible that Apache is the culprit or should
> we be looking more closely at our script or rewrite rule?
> 

The test would be to hit /cgi-bin/script.pl? with the water+pollution 
keyword.

The problem is most CGI variable processors are going to replace + with 
a space.  I doubt this is an issue with rewrite.  You might need to pass 
the URL encoded string instead of water+pollution...  That would be 
water%2Bpollution.

Rob

Re: The case of the disappearing plus sign

Posted by John ORourke <jo...@o-rourke.org>.
I wouldn't really call this a modperl question but regardless...

Chris Schults wrote:
> It appears that the "+" is getting stripped out at some point as the
> script is returning results for "water pollution" instead of
> "water+pollution". Is it possible that Apache is the culprit or should
> we be looking more closely at our script or rewrite rule?
>   
I'd suggest looking more closely at the HTTP specs... + represents a 
space in a URL so your program will be fed a space by CGI - probably 
nothing to do with the rewrite.

> To sign up for Grist by email, the world's top environmental news served
> up with a sense of humor, click here <http://www.grist.org/signup/> or
> send a blank email message to <da...@lists.grist.org> 
>   
To sign up for mod_perl, the world's top web applications platform 
served with tongue firmly in cheek, ...

John