I've got a directory that lists items by groups. if your _GET variable is available, it's utilized in a question. I must use "pretty url's", like: example/a/1/b/2/c/3/d/4 becomes example/index.html?a=1&b=2&c=3&d=4

most .htaccess good examples I see just use variables to exchange the _GET values, however i may use rules such as this:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ index.html?$1=$2&$3=$4&$5=$6 [L]
RewriteRule ([^/]+)/([^/]+)/([^/]+)/([^/]+)$ index.html?$1=$2&$3=$4 [L]
RewriteRule ([^/]+)/([^/]+)$ index.html?$1=$2 [L]

And delay pills work... However, the after i add longer and longer RewriteRules (like to &17=$18), it reduces. The final variables within the chain become some kind of array according to earlier values (in above it might build index.html?a0=a1&a3=a4)...

  • It is possible to better method of doing this?
  • It appears inefficient?
  • It is possible to limit to the amount of variables in .htaccess
  • How lengthy a guide could be?

Thanks!

mod_rewrite only supports as much as $9 and %9.

I suggest you either modify your script to make use of $_SERVER['PATH_INFO'], or else you use RewriteMap to invoke a script to change the road right into a querystring.

mod_rewrite only enables that you should have ten back-references, such as the entire matchable part (which eventually ends up departing you with only nine definable capture groups), so you are certainly restricted to that.

However, in my experience it might make a lot more sense to look at the server's REQUEST_URI/SCRIPT_NAME/PATH_INFO variable inside your script file, and parse that to obtain the key-value pairs in the URL. Then, you'd only have this inside your .htaccess:

RewriteRule On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]

And your script would take proper care of the relaxation. I do need to question though, for those who have that many GET variables, could it be really more readable if they are all converted into a "pretty" URL? In the end, for those who have twenty-some forward slashes within the URL, you might be equally rich just passing an ordinary query string at that time. It is dependent in your application though and just how customers interface with one of these Web addresses, to have valid reason for thinking of doing it by doing this.