Forum Moderators: phranque

Message Too Old, No Replies

removing query string w/ mod rewrite

         

crimsontwo

12:41 am on Mar 25, 2010 (gmt 0)

10+ Year Member



re,

I can't figure out how to do the following:

IF there is a "a=" in the query string, I want to redirect (rewrite URL in browser) to:

http :// [host where the request came to] /test / [value of "a"] /

my condition looks like this:

RewriteCond %{QUERY_STRING} at=(.*)
RewriteRule ^(.*) {HTTP_HOST}/test/%1

....it doesn't work.

if I change RewriteRule to:

^(.*) http :// 127.0.0.1 / test / %1

it works, but it appends the whole "a=whatever" string after %1.

how do I fix that?

thanks in advance. you guys are always so helpful.

[edited by: crimsontwo at 12:52 am (utc) on Mar 25, 2010]

g1smd

12:46 am on Mar 25, 2010 (gmt 0)

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



A question mark appended to the target will clear the query string.

If this a redirect, do add the [R=301,L] flags, otherwise you'll have a 302 redirect on your site.

I would put the domain name into the target, selecting www or non-www as appropriate, rather than using HTTP_HOST.

crimsontwo

12:52 am on Mar 25, 2010 (gmt 0)

10+ Year Member



Worked, thanks.