So I followed Nick Johnson's instructions on how to forward a naked domain: http://blog.notdot.net/2009/12/Naked-domains-on-App-Engine and configured GoDaddy to use a 301 redirect to the "www" subdomain of my site.
However, the problem I'm still having is that when I enter http://mydomain.com/foo/bar, it gets forwarded to http://www.mydomain.com (but no "/foo/bar"). Is the开发者_StackOverflow中文版re a way to maintain the full URL(including subdirectories and URL parameters etc.) and simply tack "www" on the front of the naked domain (e.g. so http://mydomain.com/foo/bar becomes http://www.mydomain.com/foo/bar)?
NOTE: this is not a problem when I forward a subdomain: e.g. http://foo.mydomain.com/foo/bar is successfully forwarded to http://www.mydomain.com/foo/bar
Yes this is possible, but GoDaddy doesn't support any of this stuff very well - when I evaluated them a while back, I found that they sometimes roll out a 302+302+301 (!) for their "301" service (yeah, technically it was eventually a 301 ...).
301 is supposedly better than a 302 since 301 is cached. but that's just the theory. in practice you need to actually measure different service providers to see which ones achieve the results you need the quickest. e.g. when i measured GoDaddy, they did offer 301 service but it was slower than competitor's 302 service (!).
note also that the caching difference between 301 and 302 matters less for the full URL - it's less likely that the exact subdirectories and parameters etc are cached. i doubt very much that for your purposes, a 301 will in reality outperform 302. thus i would look to the most able DNS provider for this capability.
I evaluated this a year ago and went with dyndns' "webhop" service. it's a 302 but quick. it's been working like a charm since.
Ok, here is how I am solving this:
- Set up godaddy to do top level domain forwarding with masking to a special domain on my server. E.g. forward naked domains to http://www.mydomain.com/naked_redirect. Because "masking" is turned on, what this is really doing is setting up frames and opening http://mydomain.com/naked_redirect in one of the frames. That way, http://www.mydomain.com/naked_redirect has the naked domain as the referrer.
- I set up http://www.mydomain.com/naked_redirect to look at the referrer (e.g. http://mydomain.com/foo/bar), grab the URL and determine all parts of the URL, and then have that page do a redirect to http://www.mydomain.com/foo/bar.
Hope that helps others.
精彩评论