开发者

Using mod_rewrite to remove www along with SWFAddress. Why does Safari lose content after hashtag, Chrome and FF don't?

I'm curious about the browser behavior when using mod_rewrite and a hashtag (#). Firefox and Chrome can rewrite a URL that has a 'www' and remove the 'www' while keeping the original URL, with the hashtag and fragment, no problem. That's awesome! But Safari and IE7/8 (not sure about 9) remove the 'www' and lose the hashtag and fragment during the rewrite. I'm wondering if there's a fix using mod_rewrite for the Safari and IE? Although, I suspect there isn't because I'm asking about fragments. (I have no experience with mod_rewrite, I've only been reading about it and just started using the HTML5 Boilerplate .htaccess file. I've read about how hash fragments aren't ever sent to the server and if I wanted to store or use that fragment I'd have to do something client-side with Javascript.)

I can use Twitter to show an example of what I'm talking about. If you use Chrome or FF and go to http://www.twitter.com/#!biz you'll get the rewrite of http://twitter.com/#!biz no problem, perfect. But using that same URL (with the 'www') in Safari and IE7/8 will rewrite the URL back to the main Twitter URL, without the 'www' but no hash and fragment, no deeplink. It's the same result for the Twitter URL that has #!/biz ( with the second / )

If Twitter doesn't (or can't) do anything about this Safari/IE & 'www' behavior, then maybe I shouldn't sweat it either? Is this a browser thing because there's no solution using mod_rewrite within a .htaccess file to store a hashtag fragment, right?

Specifically in my work, I'm using SWFAddress, which uses the hashtag to deep link in Flash content, which is almost exactly like a Twitter URL, except there's no '!'. I think Twitter is using the Making AJAX Crawlable approach. And just like Twitter, my URLs will rewrite fine in FF and Chrome, but bonk in Safari and IE 7/8. It doesn't seem to make a difference if the hashtag has t开发者_StackOverflow社区he '!' or not, it's still part of the fragment, no?

I started to play around with a SWFAddress version approach of Making AJAX Crawlable back when I was looking for a solution to make the content on a Flash site crawlable, but the browsers handle the mod_rewrite the same way. The removal of the 'www' works fine in FF/Chrome, bonk the fragment in Safari and IE. I have a working example for my SWFAddress Making AJAX Crawlable approach version (had to remove the link. new users to stackoverflow only get 2 URLs per post). In the end I didn't use that approach for making my Flash content searchable, but it looks promising. I think making the HTML snapshot was more work than using PHP pages, but that's a totally different subject/question.

It'd be funny if (for my first stackoverflow question) there was a really short answer like, Yeah, don't sweat it! :)

Thanks!


The part after the hash is never sent to the server with the request, so it's being lost by the browser, not Apache. Nothing you can do about that, except maybe open a bug report with the browser vendors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜