Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite

Using two back references

         

Birdman

6:45 pm on Jan 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello. I've been using mod_rewrite alot for dynamic urls. So far it's been going fine, but now I'm trying to back reference two variables in the url.

Example:

change >> mysite.com/widgets_section/blue_widgets_shop

to >> mysite.com/widgets/shop.php?shop=blue_widgets

_section and _shop are the regular expressions.

I've tried these lines:

RewriteRule ^(.*)_section/(.*)_shop$ /$1/shop.php?shop=$2
RewriteRule ^(.*)_section\/(.*)_shop$ /$1/shop.php?shop=$2
RewriteRule ^\/(.*)_section\/(.*)_shop$ /$1/shop.php?shop=$2

Birdman

7:01 pm on Jan 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The last post was incorrect. I really wanted to make this change:

mysite.com/widgets_section/blue_widgets_shop

to

mysite.com/shop.php?shop=blue_widgets&section=widgets

I got this line to work :)

RewriteRule ^(.*)_section/(.*)_shop$ /shop.php?shop=$2&section=$1

jdMorgan

10:27 pm on Jan 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Rats!

Missed all the fun... ;)

Jim