views:

43

answers:

1

This is a complicated one which I hope has a simple answer...

RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) category.php?c_id=$2&filters=$3&_p=$4&name=$1

This rule would pick up category/kitchen/10/0-0-0-0-0-0-0-0/1

with the following get vals:

category.php?c_id=10&filters=0-0-0-0-0-0-0-0&_p=1&name=kitchen

The reason filters were stored in 0-0-0-0-0-0-0-0 was because of the 9 back references limit. Each 0 was a different filter variable which I accessed by doing a split on $_GET['filter'].

I am now changing my URL to a non mod rewritten one, so that the rewrite rule becomes:

RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) category.php?c_id=$2&filters=$3&_p=$4&name=$1 [R=301,L]

Note to [R=301,L] so it becomes a 301 redirect.

This is all fine but I was wondering if there a was a clever way of splitting the 0-0-0-0-0-0-0-0 so that each 0 is a get variable. So I can get

category.php?c_id=10&f1=0&f2=0&f3=0&f4=0&f5=0&f6=0&f7=0&f8=0&_p=1&name=kitchen

Any idea?

Thanks in advance!

+1  A: 

You can use a RewriteCond to accomplish that:

RewriteCond $3 ^([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)$
RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) category.php?c_id=$2&f1=%1&f2=%2&f3=%3&f4=%4&f5=%5&f6=%6&f7=%7&f8=%8&f9=%9&_p=$4&name=$1 [R=301,L]
Gumbo
Cheers! this works great!
Lizard