mod_ReWrite to remove part of a URL

Posted by Jack on Server Fault See other posts from Server Fault or by Jack
Published on 2011-01-03T03:14:45Z Indexed on 2011/01/03 3:55 UTC
Read the original article Hit count: 226

Someone has incorrectly linked to some of my urls causing 404 erros in Google Webmaster Tools.

Here is an example

Linked URL: http://www.example.com/foo-%E2%80%8Bbar.html

Correct URL: http://www.example.com/foor-bar.html

I would like to 301 redirect any instance of this kind of incorrect linking to the correct URL. I have tried the following but it generates 404 Errors site wide.

Options +FollowSymLinks
RewriteEngine on    
RewriteRule ^foo-(.*)bar\.html$ http://www.example.com/foo-bar\.html? [L,R=301]

Could anyone let me know what I am doing wrong?

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about .htaccess