I've got a previous question which was clarified perfectly but requires an amendment and that i was not able to retort and so do produced a brand new question.

I needed a mod_rewrite that made the next:

www.example.com?page=var1&cat=var2&subcat=var3&subsubcat=var4

into this:

www.example.com/var1/var2/var3/var4/

but which covered the not compulsory utilization of var2, var3 and var4 therefore if individuals variables were empty, it might still work.

The question was clarified perfectly however it requires an amendment to utilize different area choices for var2, var3 and var4.

The code I've is:

RewriteEngine on
Options +FollowSymlinks -MultiViews

RewriteCond  %{QUERY_STRING} !^page= [NC]
RewriteRule ^([^/]+)/?$ /?page=$1 [L]

RewriteCond  %{QUERY_STRING} !^page= [NC]
RewriteRule ^([^/]+)/([^/]*)/?$ /?page=$1&cat=$2 [L]

RewriteCond  %{QUERY_STRING} !^page= [NC]
RewriteRule ^([^/]+)/([^/]*)/([^/]*)/?$ /?page=$1&cat=$2&subcat=$3 [L]

RewriteCond  %{QUERY_STRING} !^page= [NC]
RewriteRule ^([^/]+)/([^/]*)/([^/]*)/([^/]*)/?$ /?page=$1&cat=$2&subcat=$3&subsubcat=$4 [L]

This works however i require it to have the ability to make an if-or-else for the option of what area has been employed for what variable and also to differentiate.

For instance, as we possess the following two strings normally, you can easily distinguish what area applies to what variable:

www.example.com?page=var1&cat=var2&subcat=var3&subsubcat=var4

www.example.com?othervar1=var1&othervar2=var2&othervar3=var3&othervar4=var4

however for this string, it takes a chance to distinguish what area the variable is perfect for:

www.example.com/var1/var2/var3/var4/

I want the mod_rewrite to select that is getting used.

In addition to this, after i really visit a folder that does exist, it will work properly. For instance, basically visit a folder known as "test", that is a real folder:

www.example.com/test/

it uses it as being a flexible for that "page" area. Basically make use of the following with no finish forward slash:

www.example.com/test 

it results the next in to the URL:

www.example.com/test/?page=test

I want results for folders which exist normally also.

Please can someone let me know how you can do this? I'd appreciate any assist in solving this problem.

Also, can someone let me know exactly what the "-MultiViews" bit means at the start when i haven't run into this before?

Thanks.