2

I have very weird problem.

My WordPress site gets traffic to the same page with different additional parameters.

Example:

mysite.com/page1.html?m=1 
mysite.com/page1.html

It is the same page, but ?m=1 makes WP show 404 error page.

I tried 301 redirect like this (in actual HTACCESS file i also use http:// but here I cannot):

Redirect 301 /page1.html?m=1  mysite.com/page1.html

But this does not do anything.

Traffic comes from google, so I cannot change this URL structure - I have to work with what I got ... So how I fix this???

It could be either WP or HTACCESS problem ... I searched and cannot find anything - i get results for M1 rifle :(

Please help - this is a live site

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Levchik
  • 496
  • 1
  • 5
  • 19

2 Answers2

3

You can't match against the query string in mod_alias's Redirect or RedirectMatch. You need to use mod_rewrite's %{QUERY_STRING} or %{THE_REQUEST} variables. Try:

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

This will redirect any request that has the "m=1" query string and remove it.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
0

.htaccess

RewriteEngine On
RedirectMatch 301 ^/page1.html?m=1$ /page1.html

Try that see also this answer .htaccess 301 redirect of single page

Community
  • 1
  • 1
1Bladesforhire
  • 360
  • 1
  • 10