Even simple .htaccess provides me with head aches and I have to perform the following generic mapping:

http://example.com/project/controllername/key1/val1/key2/val2/.../keyN/valN

-->

http://example.com/project/controllername.xyz?key1=val1&key2=val2...&keyN=valN

example:

http://example.com/so/pagecontroller/id/1/time/12345/title/helloworld

-->

http://example.com/so/pagecontroller.xyz?id=1&time=12345&title=helloworld

Any guidance can help! Particularly with handling special chars like '/', '?' and '&' (more?) in secrets and values.

EDIT: To explain, 'project' and 'controllername' pathways are dynamic - they aren't static. Also the amount of secrets and values isn't pre-determined! I want assist in creating the htaccess file code and where you can place this file within the web tree and when apache needs restarting each time the htaccess file is modified. Thanks!

As lengthy as you won't want to choose individuals special figures, they must be not a problem. A guide for the example may be:

RewriteRule http://example.com/so/pagecontroller/id/([0-9]+)/time/([0-9]+)/title/(.*)$ http://example.com/so/pagecontroller.xyz?id=$1&time=$2&title=$3  

I do not think you'll have a dynamic quantity of variables inside a rewrite rule. But you skill may be the following:

RewriteRule http://example.com/so/pagecontroler/(.*) http://example.com/so/pagecontroler.xyz?vars=$1

Than you've got a GET parameter using the title "vars" and also the relaxation from the query like a value. You are able to than split the various secrets and values server side e.g. using the explode() function of PHP.

Try these rules:

RewriteRule ^([^/]+/[^/]+)/([^/]+)/([^/]+)(/.+)?$ $1$4?$2=$3 [QSA,N]
RewriteCond $1 !.+\.xyz$
RewriteRule ^([^/]+/[^/]+)$ $1.xyz [L]