Try:
RedirectMatch 301 ^(.*)\.html&(.*)$ /$1.html?$2
or using mod_rewrite:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.html&(.*)$ /$1.html?$2 [L,R=301]
in the htaccess file in your document root.
Question
I've made a huge mistake in my shop when creating pagination links. After the .html, instead of a question mark my code just appended an ampersand. Now Google Webmaster tools is throwing up hundreds of 404's.
I know how to fix the problem on a URL by URL basis, but is there a wildcard solution as a first off sanity check in HTAccess to check for ".html&" and replace with ".html?"?
Below are examples of my issue, myitemspage represents a category of items, so i have over 50 categories:
http://www.domain.com/myitemspage.html&page=1&limitchange=10
http://www.domain.com/myitemspage.html&page=1&limitchange=25
http://www.domain.com/myitemspage.html&page=1&limitchange=50
http://www.domain.com/myitemspage.html&page=1&limitchange=100
Thank you for any help on my self-created nightmare,
Mark.
Solution
Try:
RedirectMatch 301 ^(.*)\.html&(.*)$ /$1.html?$2
or using mod_rewrite:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.html&(.*)$ /$1.html?$2 [L,R=301]
in the htaccess file in your document root.