I am trying to create a mod_rewrite that when a user enters, or it shows in the URL:
www.example.com/var1/var2/var3/var4/
it outputs the same as
www.example.com?page=var1&cat=var2&subcat=var3&subsubcat=var4
but if there is a change in the number variables, it will still work, so the variables could be:
www.example.com/var1/
or
www.example.com/var1/var2/
or
www.example.com/var1/var2/var3/
or
www.example.com/var1/var2/var3/var4/
If I use the following, it only works for www.example.com/var1/var2/var3/var4/ but not the others:
Options +FollowSymLinks RewriteEngine On RewriteBase /
RewriteRule ^([^&]+)/([^&]*)/([^&]*)/([^&]*)/$ /?page=$1&cat=$2&subcat=$3&subsubcat=$4 [L]
If I use the following code using CHAINING, it works as a chain to an extent, but the problem is that for
www.example.com/var1/var2/
www.example.com/var1/var2/var3/
www.example.com/var1/var2/var3/var4/
it outputs the VAR1 as "/", so it is ignoring the first variable using the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([^&]+)/$ /?page=$1 [C]
RewriteRule ^([^&]+)/([^&]*)/$ /?page=$1&cat=$2 [C]
RewriteRule ^([^&]+)/([^&]*)/([^&]*)/$ /?page=$1&cat=$2&subcat=$3 [C]
RewriteRule ^([^&]+)/([^&]*)/([^&]*)/([^&]*)/$ /?page=$1&cat=$2&subcat=$3&subsubcat=$4 [L]
The order is always the same so this should be easy. How can I make this work please?