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!
You could double the number of possible back-references by splitting the regex between a
RewriteCond
and aRewriteRule
. Based on your examples, this would look something like the following:Yes, I know, it's not the most elegant solution, but it should work. You may need to play a bit with the
PATH_INFO
(e.g. switching toREQUEST_URI
or something similar) depending on your exact settings.maybe you could use flags like 'next|N' (next round) after a RewriteRule to rerun the process with an useable break condition to avoid infinite loops
see here: http://askapache.info/trunk/mod/mod_rewrite.html#rewriterule
i haven't tried this yet but it may be possible