Dear Wiki user, You have subscribed to a wiki page or wiki category on "Httpd Wiki" for change notification.
The following page has been changed by VinkoVrsalovic: http://wiki.apache.org/httpd/Recipes/QueryString The comment on the change is: Added [^/]+ example ------------------------------------------------------------------------------ Keep the existing query string using the Query String Append flag, but add {{{newstuff}}} to the end. {{{ - RerwriteRule (.*) $1?newstuff [QSA] + RerwriteRule (.*) $1?var=value [QSA] }}} === Rewriting For Certain Query Strings === @@ -47, +47 @@ === Making the Query String Part of the Path === - Take a URL of the form {{{http://example.com/path?var=val}}} and transform it into {{{http://example.com/path/var/val}}}. + Take a URL of the form {{{http://example.com/path?var=val}}} and transform it into {{{http://example.com/path/var/val}}}. Note that this will work only for a single key=value pair. {{{ RewriteCond %{QUERY_STRING} ^(.*)=(.*)$ RewriteRule ^/path /path/%1/%2 @@ -61, +61 @@ RewriteRule ^/path/(.*)/(.*) /path?$1=$2 }}} + Another take on this example could be the following: + + {{{ + RewriteRule ^/path/([^/]+)/([^/]+) /path?$1=$2 + }}} + + Which serves the same basic purpose, but changing {{{.*}}} to {{{[^/]+}}} ensures that there is something between the / characters, is more explicit, probably faster (not sure about this one though), and, at the very least, serves as a better starting point to modify if your conditions are more complex. +
