Forum Moderators: phranque

Message Too Old, No Replies

Redirecting a PHP get request

How can I redirect a php get request URL?

         

BigDogUK

2:36 pm on May 24, 2006 (gmt 0)

10+ Year Member



Hey all. I'm just sorting my .htaccess to make all my URLs nice. I've got everything sorted except my search.

Basically. I want to redirect:

/sendsearch.php?search=something

TO

/search/something/

Now, I've been fine doing the reverse. ie. getting nice urls to translate to requests. But when I try:

RewriteRule ^sendsearch\.php?search=([A-Za-z]+)$ /search/$1/ [R]

It says it can't find anything. It all seems to go wrong at the? mark. Can anyone help me with this?

Thanks

BigDogUK

3:23 pm on May 24, 2006 (gmt 0)

10+ Year Member



I tried escaping the question mark by the way.

ie.

RewriteRule ^sendsearch\.php\?search=([A-Za-z]+)$ /search/$1/ [R]

jdMorgan

9:19 pm on May 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use RewriteCond to test the query string; It is not visible to RewriteRule. If you don't want to handle the URL and query separately, you can use RewriteCond and examine %{THE_REQUEST}, which is the entire request, as received from the client, e.g. "GET /page?name=alvuw HTTP/1.1"

More here [webmasterworld.com].

Jim