Use this .htaccess code to have recursion based translation of key/value
based URI:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)(/.*)?$ $3?$1=$2 [N,QSA]
RewriteRule ^(/[^/]+|[^/]+/|/?)$ /index.php [L,QSA]
Using these rules a URL of 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
treating each pair of URL segments separated by / as a name-value pair for QUERY_STRING. BUT keep in mind if URI doesn't have even number of segments eg: http://localhost/n1/v1/n2/
then it will be redirected to http://localhost/?n1=v1
, discarding extra n2.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…