I had some urls show up in my google sitemaps for one of my sites with "404 Not found" errors for a bunch of urls that had "%23comment-155" looking urls instead of "#comment-155"
So I had to redirect incoming links that contained
Code:
/article.html%23comment-155
to
/article.html#comment-155
The fix:
Code:
RewriteRule ^(.*)\.html([^c]+)comment-(.+)$ http://www.site.com/$1.html#comment-$3 [R=301,L,NE]
Heres what was being requested by browsers as demonstrated by the apache log files.
Code:
"GET /2006/htaccess/speed-up-sites-with-htaccess-caching.html%23comment-155 HTTP/1.1" 200 2617 "-"
Once the fix is in place that same request looks like this.
Code:
"GET /2006/htaccess/speed-up-sites-with-htaccess-caching.html%23comment-155 HTTP/1.1" 301 683 "-"
"GET /2006/htaccess/speed-up-sites-with-htaccess-caching.html HTTP/1.1" 200 24690 "-"
And the users browser is correctly redirected using a Search Engine Friendly 301 Redirect to the correct URL, including the anchor!
For discussion of the problem check out
http://www.webmasterworld.com/forum92/5188.htm