Forum Moderators: phranque

Message Too Old, No Replies

redirect with ? in url

         

ads112001

7:56 pm on Nov 5, 2010 (gmt 0)

10+ Year Member



Trying to redirect:
/common/offers/landing.php?offer=randomacts
to
/promotions/random-acts/index.html
but i believe the ? is giving me problems.
Any thoughts?

g1smd

8:38 pm on Nov 5, 2010 (gmt 0)

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



Use a preceding RewriteCond looking at QUERY_STRING to examine all parts after the question mark.

Use a RewriteRule for the redirect itself.

When you redirect, do not include the "index.html" part in the target URL, end the target with a trailing slash.

The redirect target needs to include the protocol and domain as well the [R=301,L] flags.

ads112001

8:57 pm on Nov 5, 2010 (gmt 0)

10+ Year Member



so i'm trying this:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(offer=randomacts$)
RewriteRule ^(.*) /promotions/random-acts/ [R=301,L]

but it's taking me to /promotions/random-acts/?offer=randomacts instead of /promotions/random-acts/

g1smd

10:50 pm on Nov 5, 2010 (gmt 0)

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



Add a question mark to the end of the target URL. This will clear the query string value.

Add the protocol and domain name to the target URL.

Be aware that if there are any other parameters included with the request, that your code will not redirect the request.

ads112001

2:20 pm on Nov 8, 2010 (gmt 0)

10+ Year Member



Perfect thank you so much for all your help!