Forum Moderators: phranque

Message Too Old, No Replies

query string redirect not working

query_string rewrite

         

lizzyb

8:58 am on Mar 27, 2012 (gmt 0)

10+ Year Member



Hello,

I'm new to this forum and to redirects and need a little help.

I'm trying to redirect:

www.example.com/cgi-bin/ss000334.pl?PRODREF=1516&NOLOGIN=1
to
www.example.com/tools/Example_Page.html

I'm using the RewriteCond and RewriteRule below, but when I follow the original link, it doesn't redirect and my site gives a message that the product ref doesn't exist anymore.

RewriteCond %{QUERY_STRING} ^PRODREF=1516&NOLOGIN=1$
RewriteRule ^cgi\-bin/ss000334.pl$ /tools/Example_Page.html? [R=301,L]

Any help you can offer would be greatly appreciated.

phranque

1:41 pm on Mar 27, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



- you don't need to escape the '-' in the pattern
- you should include the hostname in the substitution to canonicalize the hostname

RewriteRule ^cgi-bin/ss000334.pl$ http://www.example.com/tools/Example_Page.html? [R=301,L]

i might have missed something else but try that for starters...

g1smd

7:29 pm on Mar 27, 2012 (gmt 0)

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



I've found that sometimes you just cannot redirect cgi-bin URL requests. The CGI handler grabs the request before mod_rewrite gets a sniff of what's going on.

lucy24

10:03 pm on Mar 27, 2012 (gmt 0)

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



The CGI handler grabs the request before mod_rewrite gets a sniff of what's going on.

Does that mean she* needs to start by adding something to the CGI handler to say "If you get a request in this format, pass it through unchanged so Apache can deal with it"?

Funny. There's a post right next door that looks as if it's 80% php, but it may really be a strictly Apache question. Here's the reverse :)


* Quick edit from "he" after pondering the OP's name. Oops.

lizzyb

8:30 am on Mar 30, 2012 (gmt 0)

10+ Year Member



phranque, I've changed the RewriteRule to remove the escape and included the hostname in the substitution, but it hasn't changed anything. Clicking the link still takes me to the original location.

g1smd, can you suggest any resources that I can use to guide me through the changes I need to make to the CGI handler to accept my URL requests? I don't know anything about CGI handlers but I'm willing to learn :)