Sun Apr 10 10:55:35 EDT 2011

Apache rewrite rules : Matching on CGI inputs?

I want to redirect a wordpress URL like:


This doesn't seem to work.  My guess is that it's because the script
parameter page_id=1520 is handled differently than the base url blog/

This can be solved by using RewriteCond on the QUERY_STRING
environment variable.  By default the query is passed through.  To
kill it or otheriwise change it add a question mark.

  RewriteCond %{QUERY_STRING} ^page_id=1520$
  RewriteRule ^/blog/$ http://deyofthephoenix.com/herstories/?

From [1]:

    Modifying the Query String

    By default, the query string is passed through unchanged. You can,
    however, create URLs in the substitution string containing a query
    string part. Simply use a question mark inside the substitution
    string to indicate that the following text should be re-injected
    into the query string. When you want to erase an existing query
    string, end the substitution string with just a question mark. To
    combine new and old query strings, use the [QSA] flag.

[1] http://httpd.apache.org/docs/current/mod/mod_rewrite.html