You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wiki-changes@httpd.apache.org by Apache Wiki <wi...@apache.org> on 2007/05/30 12:46:06 UTC

[Httpd Wiki] Trivial Update of "Recipes/QueryString" by VinkoVrsalovic

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.
+