Forum Moderators: phranque

Message Too Old, No Replies

Merge/remove query string parameters

Merging 2 query string parameters into one

         

civgroup

7:12 pm on Jun 30, 2008 (gmt 0)

10+ Year Member



I'm all out of ideas. What I'm trying to accomplish is to permanently redirect this:

domain.com/cat.php?section=12&type=20

into this:

domain.com/cat.php?type=12

(and yes, I'm trying to redirect the initial 'section' into the eventual 'type' and remove the 'section' parameter altogether [albeit preserving its value for use with 'type'])

So far I have this, and I've tried different variations of it with no success:


RewriteCond %{QUERY_STRING} sec=([0-9]+)
RewriteRule ^([0-9]+)&type=([0-9]+)$ /category.php?type=$1? [R=301,NC,L]

Any help is much appreciated.

jdMorgan

10:36 pm on Jun 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Based on what you wrote, I'd suggest:

RewriteCond %{QUERY_STRING} ^section=([0-9]+)&type=
RewriteRule ^cat\.php$ /category.php?type[b]=%1[/b] [R=301,NC,L]

RewriteRule can never 'see' any part of the requested query string; it must be handled by RewriteCond.

Jim

[edited by: jdMorgan at 10:47 pm (utc) on June 30, 2008]

civgroup

1:15 am on Jul 1, 2008 (gmt 0)

10+ Year Member



Bingo! That did it. I'm ashamed that I've never before seen the %1 backreference used - I'm going to look that one up.

Thanks for straightening me out.