Forum Moderators: phranque

Message Too Old, No Replies

Redirect dynamic to static URL appends query string

         

oswald_yang

11:45 am on Sep 28, 2010 (gmt 0)

10+ Year Member



Hey all,

I need to redirect:

'http://www.site1.com/pls/cms/cnbc.show_detail?p_sid=238'

to

'http://www.site2.com/programming'

I've tried:

RewriteRule ^/pls/cms/cnbc\.show_detail\?p_sid=238$ http://www.site2.com/programming/ [R,L]


AND

RewriteCond %{QUERY_STRING} ^p_sid=238$
RewriteRule ^/pls/cms/cnbc\.show_detail$ http://www.site2.com/programming/ [R,L]


The 1st has no apparent effect, while the 2nd is redirecting BUT it appends the query string:

'http://www.site2.com/programming/?p_sid=238'

I'm not sure where I'm going wrong. Any pointers would be greatly appreciated.

Thanks,
Charl

oswald_yang

1:23 pm on Sep 28, 2010 (gmt 0)

10+ Year Member



UPDATE:

Solved it. Kept on searching Google after posting the above and found the answer in these forums :) [webmasterworld.com...]

The corrected code is:

RewriteCond %{QUERY_STRING} ^p_sid=238$
RewriteRule ^/pls/cms/cnbc\.show_detail$ http://www.site2.com/programming/? [R,L]


Note the '?' after 'programming/' - for those of you that don't know. To remove the query string append from the destination URL, one needs to add a '?' at the end of the destination URL.

Cheers,
Charl

jdMorgan

1:45 pm on Sep 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you found the answer, but sorry you didn't get a reply...

We have lots of "askers" here, and few "answerers," so thanks for re-posting the solution.

Jim

g1smd

2:22 pm on Sep 28, 2010 (gmt 0)

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



I was eating a meal in the time between the original ask and the repost. :)