Q:

htaccess mod_rewrite subdomain

I have a mobile url that i want to redirect to subdomain m.
i.e. example.com/mobile  to m.example.com
However, when I have the url example.com/mobile/boston_resources/
it redirects to m.example.com/mobile/boston_resources/?city=boston
(instead of m.example.com/mobile/boston_resources/)
I'm using:
 RewriteCond %{QUERY_STRING}  page=[1-9]+        [NC,OR]
 RedirectMatch 301 ^/mobile/(.*)$ http://m.example.com/$1

Any help appreciated

A:

Add a trailing ? to your match to drop any query string present.
RedirectMatch 301 ^/mobile/(.*)$ http://m.example.com/$1?

Secondly, a RewriteCond does not apply to a RedirectMatch but a RewriteRule.
RewriteCond %{QUERY_STRING}  page=\d+ [NC]
RedirectRule ^mobile/(.*)$ http://m.example.com/$1? [R=301,L]

[OR] was dropped because there's only one RewriteCond and [1-9]+ was changed to include 10 etc. Please note that putting a RewriteCond says that only redirect when you have page= in the query string. If you need the redirection regardless of that, drop the condition and just keep the rule.

