Dynamically rewrite URLs upon the user's selection - is it possible?

Posted by jitzo on Pro Webmasters See other posts from Pro Webmasters or by jitzo
Published on 2012-01-14T20:55:56Z Indexed on 2013/06/24 16:38 UTC
Read the original article Hit count: 241

Filed under:
|
|
|

In my PHP based web application, there's a form that generates a URL according to the user's selection. The form has 7 different fields, each one of them affects the final URL, none of them is mandatory.

The final URL can be:

/field1/user_setting_of_field1/field3/user_setting_of_field3/field6/user_setting_of_field6/

or just:

/field4/user_setting_of_field4

these URLs should be rewritten to-

/results.php?field1=user_setting_of_field1&field3=user_setting_of_field3&field6=user_setting_of_field6

and:

/results.php?field4=user_setting_of_field4

Is it possible to create a single rewrite rule that will cover these variations? I'd hate to create different rewrite rule for every possible scenario, it'll take forever...

I'm currently developing the app on a Windows machine with IIS 7.5, but will eventually deploy it to an Apache server.

Is it possible in both? I currently need to solve it for the IIS environment, and later on for Apache.

© Pro Webmasters or respective owner

Related posts about mod-rewrite

Related posts about url-rewriting