title: Rewriting url conditionally and making everything lowercase
body: <p>So, I've urls like this: <code>https://foobar.com/blog?category=Foo+Bar</code> , where the actual get parameter value may or may not have plus( + ) character in it.</p>
  <p>What I'm trying to do is first make parameter value lowercase, in all cases, and then, if parameter value contains plus character( + ), replace it with hyphen.</p>
  <p>In the end, I'm trying to get <code>https://foobar.com/blog?category=Foo+Bar</code> rewritten to <code>https://foobar.com/category/foo-bar</code></p>
  <p>This is what I got so far:</p>
  <pre><code>Options +FollowSymLinks
  RewriteEngine On
  
  RewriteCond %{REQUEST_URI} ^/blog
  RewriteCond %{QUERY_STRING} category=([^/]+)+([^/]+)$
  RewriteRule (.*) /category/%1-%2? [R=301,L]
  </code></pre>
  <p>Now, that's somewhat close, but it actually rewrites <code>https://foobar.com/blog?category=Foo+Bar</code> to <code>https://foobar.com/category/Foo+Ba-r</code>.</p>
  <p>Any help would be much appreciated.</p>