Forum Moderators: phranque
example.com/app/param1-value1/param2-value2/
to rewrite to
index.php?param1=value1¶m2=value2
and so on and so on. The problem is that my application uses a "module" parameter on every page, so I'd like a special exception for it to make it more user-friendly. I want the first param-value pair in the URL to assume the param name is "module", so it can be omitted in the URL. Example:
example.com/app/modname/param1-value1/param2-value2/
becomes
index.php?module=modname¶m1=value1¶m2=value2
I've tried many ways of doing this, but being able to support an unlimited number of parameter-value pairs AND the special "module" case is tricky. Is there a way to do this with the regular RewriteRule and RewriteCond commands rather than an external script? Can anyone provide a solution or starting point for me?
Much thanks,
-Matt
If "/app/" at the beginning of the local URL-path implies that whatever follows "/app/" is to be used as the value for the modname, then this presents no particularly-difficult challenge. More problematic is the statement, "able to support an unlimited number of parameter-value pairs."
If you intend to use mod_rewrite, then there *will* be a challenge, though not an insurmountable one, if you try to use more than five name/value pairs. This is because of the nine-backreference-creation-limit for a single RewriteRule or RewriteCond.
As I did in an earlier thread today, I'll recommend that you start with Changing Dynamic URLs to Static URLs [webmasterworld.com]. Then post your best-effort code as a basis for discussion.
Jim