1

I have a blog that I recently migrated from it's original platform into a self-hosted WordPress site. The old platform appended a query string to URLs for mobile views. This doesn't have any connection in the new responsive site, so URLs with those query strings result in 404 errors.

What I need is a regex for my .htaccess that will strip off the query string ?m=1 from a URL. So, for example, "www.example.com/post/?m=1" should rewrite or redirect to "www.example.com/post/"

What I have so far is this:

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

Which does absolutely nothing :)

Suggestions?

1
  • My issue was one of syntax. The correct solution is [here][1]. Note the importance of placement when using this solution in a WordPress site. [1]: stackoverflow.com/questions/14071671/… Commented Oct 4, 2015 at 1:47

2 Answers 2

1

The problem is the trailing slash in /post/?m=1

#stip trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{QUERY_STRING}  ^m=1$ [NC]
RewriteRule ^(.*)$ $1? [R=301,L]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Marcos. This doesn't have any effect, either.
0

My issue was one of syntax. The correct solution is here. Note the importance of placement when using this solution in a WordPress site.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.