My old urls may have one or more spaces in them. In the browser they appear as %20, which is also what google webmaster tools tell me. Recently I internally changed all dynamically generated urls so that they no longer generate spaces, but a plus-sign instead (+). The problem is with the large number of urls with space that has already been indexed by google and pals, which make them duplicate pages with same content.
I've also gone through zillions of related answers on SO, unfortunately nothing worked for me. This is the last htaccess rule I tried, before I gave up :
redirectMatch 301 /book_list.php?(.*)\s|%20(.*)$ http://www.example.com/book_list.php?$1+$2
But it doesnot lead to any re-direction. The address-bar still shows the url with the space or %20.
This are examples of sample urls which I would like to redirect:
- http://www.example.com/book_list.php?searchtype=author&search=John Grisham
- http://www.example.com/book_list.php?searchtype=author&search=Joh%20Grisham
- http://www.example.com/book_list.php?searchtype=title&search=Fire in the Hall
- http://www.example.com/book_list.php?searchtype=title&search=Fire%20in%20the%20Hall
The corresponding re-directions should be to : http://www.example.com/book_list.php?searchtype=author&search=John+Grisham and http://www.example.com/book_list.php?searchtype=title&search=Fire+in+the+Hall
I have added canonical url to all pages as the url+with+plus+sign, which hopefully should help a bit ...