stuck on URL Rewrite

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

stuck on URL Rewrite

Post 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!
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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 ..... [
Post Reply