prettyPhoto utilizes hashtags, but if they get encoded (to %23), most browsers will bring up a 404 error. This has been discussed before:
You get a 404 error because the #callback part is not part of the URL. It's a bookmark that is used by the browser, and it's never sent in the request to the server. If you encode the hash, it becomes part of the file name instead.
Why would a hash become part of the file just because it's URI-encoded? Isn't it a bug?
I'm asking because prettyPhoto uses hashtags and suffers from the same issue. I think adding a '?' before the hash is the most elegant solution, I'm just at a bit of a loss how to do it in the existing code:
function getHashtag(){ url=location.href; hashtag=url.indexOf('#gallery')!==-1)?decodeURI(url.substring(url.indexOf('#gallery')+1,url.length)):false; return hashtag; } function setHashtag(){ if(typeof theRel=='undefined')return; location.hash=theRel+'/'+rel_index+'/'; } function clearHashtag(){ if(location.href.indexOf('#gallery')!==-1)location.hash=""; }
Any other suggestions? I'll look into tweaking my 404 page, but that seems more like handling a problem rather than preventing it.
Thanks!
EDIT: Since evidently there's nothing wrong with the way prettyphoto handles those hashes, I ended up adding these rules to my apache server:
RewriteRule ^(.*).shtml(%23|#)$ /$1.shtml [R=301,NE,L]
RewriteRule ^(.*).shtml([^g]+)gallery(.+)$ /$1.shtml#gallery$3 [R=301,NE,L]
They successfully handle the cases where %23 caused issues.