I made a mistake (I don't know how) on my .htaccess and a part of my artilcle's links on Google have changed from:
mysite/articles/isfahan_articlesXXX.html
To:
mysite/maghalat.php/isfahan_articlesXXX.html?id=XXX
Where XXX is article's ID.
My current .htaccess part that contains articles is:
RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1
Redirect 301 ^maghalat.php/isfahan_articles([0-9]+).html?id=([0-9]+)$ mysite/articles/isfahan_articles$1.html
However it still will not redirect:
mysite/mghalat.php/isfahan_articlesXXX.html?id=XXX
To:
mysite/articles/isfahan_articlesXXX.html
I would also like to remove this link from Google:
mysite/articles/isfahan_articlesXXX.html
<link rel="canonical" href="PROPER_URL" />and within a month or two (or even faster) Google will forget your wrong URLs in favour of correct one (as long as you will not publish wrong URLs on your site again). Just google for "link rel canonical" for exact instructions.Redirect&RedirectMatchdirectives do not match query strings. You current rule will NEVER match; 2) You are using regex inRedirectdirective -- should beRedirectMatch-- read the docs; 3) Even then -- URL is wrong as it should start with leading slash; 4) The only way to match query string is to use RewriteRule in conjunction with RewriteCond; 5) You still can easily create redirect loop -- the rewrite rule has to be quite sophisticated to handle this. Considering all of the above -- go rel=canonical route.