OK first the parameters of MultiViews : according to the Apache manual:
Content negotiated "MultiViews" are allowed using mod_negotiation.
In short, if you have a file called foo.html , and if the browser requests http://example.com/foo , then Apache automatically finds and adds the extension and sends foo.html to the browser, rather than throwing 404 . This causes many Rewrite rules to fail, so I turned it off at the beginning in answer to your previous question.
Now, to exclude real directories from rewriting rules, we need an additional condition: RewriteCond %{REQUEST_FILENAME} !-d
To support multiple pretty url schemes:
You have few options here. Please tell me which one you would like to have, and I will provide the rules for this.
Option 1: You have both var name and var value in your url:
www.example.com/page/var1/cat/var2/subcat/var3/subsubcat/var4 OR
www.example.com/othervar1/var1/othervar2/var2/othervar3/var3/othervar4/var4
This gives you maximum flexibility and is very easy to handle in rewriting rules if you are ready to go this route. For this Rewrite parameter, the rules should be written only once, and you will be fine for future changes, since long variables do not change
Option 2: You have a start difference for each circuit. For instance:
www.example.com/handler1/var1/var2/var3/var4 OR
www.example.com/handler2/var1/var2/var3/var4
This gives you a shorter url but does not provide the flexibility like the previous option. But it is also very easy to handle in rewriting rules. However, for this option, rewrite rules must be written for each combination.
So I would recommend option 1 and would be happy to prepare .htaccess for you if you like this option too.
.htaccess file for option 2
Options +FollowSymlinks -MultiViews RewriteEngine on # 404 handler ErrorDocument 404 /notFound.php RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^handler1/([^/]+)/?$ /?page=$1 [NC,QSA,L] RewriteRule ^handler1/([^/]+)/([^/]+)/?$ /?page=$1&cat=$2 [NC,QSA,L] RewriteRule ^handler1/([^/]+)/([^/]*)/([^/]*)/?$ /?page=$1&cat=$2&subcat=$3 [NC,QSA,L] RewriteRule ^handler1/([^/]+)/([^/]*)/([^/]*)/([^/]*)/?$ /?page=$1&cat=$2&subcat=$3subsubcat=$4 [NC,QSA,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^handler2/([^/]+)/?$ /?othervar1=$1 [NC,QSA,L] RewriteRule ^handler2/([^/]+)/([^/]+)/?$ /?othervar1=$1&othervar2=$2 [NC,QSA,L] RewriteRule ^handler2/([^/]+)/([^/]*)/([^/]*)/?$ /?othervar1=$1&othervar2=$2&othervar3=$3 [NC,QSA,L] RewriteRule ^handler2/([^/]+)/([^/]*)/([^/]*)/([^/]*)/?$ /?othervar1=$1&othervar2=$2&othervar3=$3othervar4=$4 [NC,QSA,L]
.htaccess for option 1
Options +FollowSymlinks -MultiViews RewriteEngine on # 404 handler ErrorDocument 404 /notFound.php RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)(/.*)?$ $3?$1=$2 [N,QSA,DPI] RewriteRule ^(/[^/]+|[^/]+/|/?)$ /index.php [L,QSA,DPI]
Using these rules, the URL http://localhost/n1/v1/n2/v2/n3/v3/n4/v4 will be INTERNALLY redirected to http://localhost/?n4=v4&n3=v3&n2=v2&n1=v1 , processing each pair of URL segments separated by / , like a name-value pair for QUERY_STRING. BUT remember, if the URI does not even have the number of segments, for example: http://localhost/n1/v1/n2/ , then it will be redirected to http://localhost/?n1=v1 , discarding the extra n2.