Combine three rules in one

New to mod_rewrite? This is a good place to start.

Combine three rules in one

Postby Frozen Kiwi » Fri Feb 17, 2006 11:48 pm

I have three banal redirect rules:
Code: Select all
# matches http://www.site.com/index.php?category1=var1&category2=var2&page=var3
RewriteRule ^([^/]+)/([^/]+)/page([0-9]+)\.html$ index.php?category1=$1&category2=$2&page=$3 [NC,L]

# matches http://www.site.com/index.php?category1=var1&category2=var2
RewriteRule ^([^/]+)/([^/]+)/$ index.php?category1=$1&category2=$2

# matches http://www.site.com/index.php?category1=var1
RewriteRule ^([^/]+)/$ index.php?category1=$1


It works. But I suspect the rules are somewhat conflicting, let alone there must be more elegant solution. So here comes a simple question: is there a way to combine/simplify the above rules? I was messing around with the ^([^/]+)?/?([^/]+)?/?([^/]+)?/?$ syntaxes - to no avail. :( Any help is appreciated.
Frozen Kiwi
 
Posts: 1
Joined: Fri Feb 17, 2006 11:07 pm

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 39 guests

cron