Forum Topic: Eliminating mobile requests

Forum: .htaccess Forum : Redirecting • Posted by Bruno Mertins • Updated:

Hi Jeff,

Wondering if you could help me. I'm trying to figure out the right way to simply strip the ?m=1 query string from my urls. Used to have a mobile site but now I went responsive. Could you give me an idea on how to fix these using HTAccess? I read the https://perishablepress.com/stop-404-requests-for-mobile-versions-of-your-site/ example but it does not have any query string examples, which I could use.

2 Replies to “Eliminating mobile requests”

Jeff Starr
Posted by Jeff Starr

Hi Bruno,

Yes, here is an example of removing the query string from requests:

<IfModule mod_rewrite.c>
	RewriteCond %{QUERY_STRING} ^m=1 [NC]
	RewriteRule (.*) http://example.com/$1? [R=301,L]
</IfModule>

The trick is the question mark appended to the target of the RewriteRule. Note that this is just an example, so please customize with your domain and test thoroughly.

Posted by Bruno Mertins •

Thanks for the example, it now works perfectly...