Forum Moderators: phranque

Message Too Old, No Replies

Using RewriteRule with regrex AND session variables

         

setme

8:14 pm on May 10, 2005 (gmt 0)

10+ Year Member



Totally new here and fairly new to .htaccess and rewriterule. I know this has been asked a zillion times and I tried searching but couldn't find a simple example.

I am able to use basic rewrites such as:

RewriteRule ^products/([0-9]+)/$ /products.php?id=$1

which predicitably does the following:

[mysite.com...] to [mysite.com...]

No probem there at all when it can be passed as a cookie. The problem is when I use phpsessions and a user has cookies disabled. The PHPSESSID is dropped completely as well as any other GET arguments. So the following happens:

[mysite.com...] still goes to [mysite.com...]

without the PHPSESSID or test variables. The variables are in the url but they aren't read by products.php.

I'm guessing the solution relies on RewriteCond but I can't figure out the correct syntax. Any help or link appreciated.

jdMorgan

9:16 pm on May 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



setme,

Welcome to WebmasterWorld!

See the mod_rewrite RewriteRule documentation [httpd.apache.org], specifically the [QSA] and [L] flag definitions.


RewriteRule ^products/([0-9]+)/$ /products.php?id=$1 [QSA,L]

Jim

setme

9:23 pm on May 10, 2005 (gmt 0)

10+ Year Member



That did it Jim!

Now I feel stupid for not RTFM. The disclaimers for mod_rewrite had me so intimidated. I still think it's voodoo.

You definitely saved my bacon today. Thanks again.