Google picked up the following URL and ranked it:
http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 (the item_id=99 part should not be there).
Since I picked up the error and fixed it, I have added the following line to my htaccess:
RedirectPermanent /yyy/zzz-99.php?item_id=99&sort=1 http://www.example.com/yyy/zzz-99.php?&sort=1
However that redirect does not work. Any clue on what i am doing wrong?
I think you need mod_rewrite to achieve even that single replacement, because includes a query string.
You may try this in the .htaccess file in root directory, provided mod_rewrite is enabled:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/yyy/zzz-99\.php [NC]
RewriteCond %{QUERY_STRING} item_id=99&sort=1 [NC]
RewriteRule .* /yyy/zzz-99.php?&sort=1? [NC,L,R=301]
Redirects
http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1
to
http://www.example.com/yyy/zzz-99.php?&sort=1
For silent mapping, remove R=301 from [NC,L,R=301].
Check the name of your .htaccess file. Make sure it starts with a period.
redirect 301 /index.html http://www.domain.com/index.html
redirect permanent /index.html http://www.domain.com/index.html
redirectpermanent /index.html http://www.domain.com/index.html
use 301 redirect in .htaccess:
Redirect 301 http://www.example.com/yyy/zzz-99.php?item_id=99&sort=1 http://www.example.com/yyy/zzz-99.php?sort=1
Redirect 301 (from) (to)