Page 1 of 1

stuck on URL Rewrite

Posted: Sun Jan 29, 2006 7:30 am
by mzfp2
Hi there,

I'm trying to rewrite a slightly confusing (for me) url to a php readable url, which is just as confusing,

basically something like this

http://localhost/category/category2/category3

The number of categories that may be present is dynamic (upto 4 I should think)

and I would need to rewrite this into something as

php/browse.php?Cat1=%&Cat2% etc

Don't have a clue how to acheive this tho, any help would be great!

Posted: Sun Jan 29, 2006 10:25 pm
by josh
You will need to check for the maximum number first, then the next lowest, etc...

Code: Select all

# 4 cats
RewriteRule ^/(.+)/(.+)/(.+)/(.+)$ /script.php?cat1=$1&cat2=$2 ..... 
# 3 cats
RewriteRule ^/(.+)/(.+)/(.+)$ /script.php?cat1=$1&cat2=$2 ..... [