Forum Moderators: phranque
However, I've been unable to find in forums something which I'm convinced exists. Most people ask specific questions and get a specific answer. I think however something more universal is in order, and although I'm sure someone has written it somewhere, I can't find it.
Last month, after a day searching around, I came up with a rule to insert in httpd.ini file on an IIS server that would write:
http://www.example.com/foo.asp?A=a&B=b&C=c
to
http://www.example.com/A/a/B/b/C/c/foo.asp
The great thing is that the rule works regardless of a) the number of parameters or b) the order in which they appear. I wrote it up [in my blog].
Now my question is what is the code that will work for 90% of people needing to rewrite dynamic URL's as static in the Apache world?
How do I write:
http://www.example.com/foo.php?A=a&B=b&C=c
to
http://www.example.com/A/a/B/b/C/c/foo.php
... regardless of the number of parameters or order in which they appear?
[edited by: jdMorgan at 5:15 pm (utc) on July 6, 2005]
[edit reason] Removed URL per Terms of Service. [/edit]
If you have access to httpd.conf, another option is to process the request using an external cgi script--something like PERL that has better multiple-search-and-replace capabilitied than mod_rewrite.
Finally, you could use mod_rewrite to pass *all* requests matching a very basic template to your script, and do the parameter extraction within the script itself.
Jim