RedirectMatch and Query String
It's not possible to use RedirectMatch
in this case unfortunately; the query string is not part of URL string that RewriteMatch
is compared to.
The second example works because the query string the client sent is re-appended to the destination URL - so the optional match is matching nothing, the $1
replacement is an empty string, but then the client's original query string is stuck back on.
A RewriteCond
check against the %{QUERY_STRING}
will be needed instead.
RewriteCond %{QUERY_STRING} page=([^&]+)
RewriteRule ^/redirect\.php$ http://somewhereelse.com/%1? [R=302,L]