- 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.