为特定参数重写htaccess的代码

I am non ech guy and trying to get a rewrite code which I can use in htaccess for file specific parameter. Basically there are some urls with "?m=0" OR "?m=1" which I want to redirect. Like

Old url: www.abc.com/nokia.html?m=1

New URL: www.abc.com/nokia.html

Old url: www.abc.com/nokia.html?m=0

New URL: www.abc.com/nokia.html

I want to redirect code which is applied only when these 2 specific m=1 OR m=0 are present. In case there is any thing else than m=1 or m=0, the redirect shall not get applied.

I am using:

RewriteCond %{THE_REQUEST} \ /([^\?\ ]*)\?

RewriteRule ^ /%1? [L,R=301]

But it gets applied in all urls and hence I can access admin pages where "?" is used with other parameter.

Can anyone plz mention the code which I can use in very specific cases. Thanks in advance.

Use this rule:

RewriteCond %{QUERY_STRING} ^m=[01]$ [NC]
RewriteRule ^(.*)$ /$1? [R=301,L,NC]