Forum Moderators: phranque

Message Too Old, No Replies

Mod_Rewrite problems

Syntax to get Rewrite working

         

ricksterv4n1x8

11:56 pm on Nov 18, 2005 (gmt 0)

10+ Year Member



I need to redirect a single page with a url like this:

"mainpage\.php\?id=16$"

to this:

"h*tp://w*w.domain.com/products/tools"

however the following syntax doesn't seem to do the trick in my .htaccess file:

RewriteEngine on
RewriteRule ^/mainpage\.php\?id=16$ h*tp://w*w.domain.com/products/tools/

Other than the fact I have asterisks in my coding, any suggestions? I thought mod_rewrite was easy to implement but how come it doesn't work with my PHP files that have id numbers in them?

jdMorgan

12:08 am on Nov 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Query strings are not part of a URL, they are data attached to a URL to be passed to a resource *at* that URL. Therefore, they are handled separately in mod_rewrite.

Use
RewriteCond %{QUERY_STRING} ^your_pattern$
to match and/or create back-reference to query string data.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

ricksterv4n1x8

12:34 am on Nov 19, 2005 (gmt 0)

10+ Year Member



Thank-you. This gets me going down a new and hopefully more successful path.