JavaScript uses a security model called the same-origin policy. There are differences in the implementation between different browsers but here's the gist: JS may modify the DOM if-and-only-if the domain containing the script shares the domain of the DOM. Loosely, the check is done by comparing document.domain strings. If the strings match, everything is kosher.
You can truncate document.domain by lopping off period delimited prefixes. Even if you lop foo.com down to the TLDs, you won't be able to do the same trick and cut bar.com down and get scripts to run in the same context.
If you're hosting content on blog.example.com and example.com, an attack on blog.example.com could truncate the document.domain down to 'example.com' and execute malicious script on the primary domain.
I would recommend using blog.example.com and www.example.com, but never example.com.
* a lot of blogging apps/readers etc. look for feeds at standard endpoint urls such as /feed.xml /xmlrpc etc. all the plugin urls etc. will also be at the standard urls
* you can set auth cookies for the subdomain so you can isolate logged in commenters etc. (you can have path=/blog on cookies but most blogging apps don't support it).
* sep analytics (also possible on sub-dirs but you can visitor track and x-ref between domains).
pro on folder because:
* SEO counts to your main domain (see : http://www.christonium.com/SearchEngineMarketing/subdomain-d...)
http://www.mattcutts.com/blog/subdomains-and-subdirectories/
if my clients are REALLY worried about SEO, i always recommend subfolder. if they don't care or don't expect tons of backlinks to their blog, subdomain is generally easier to manage so i recommend that.
I was listing the benefits of subdomain/subfolder and on subfolder seo is the only one I could think of
After 5 years of trying to house web applications within subdirectories of subdirectories of sites for our university, we've grown tired of the endless configuration nightmares that many apps require. Sticking a new folder of static pages somewhere is trivial, but configuring Rails apps, forums, third party services, and other things we purchase to work properly at the subdirectory level is so much more painful. It often involves reverse proxy settings and content rewriting, which doesn't always play nice if the directory structure is uneven.
So now we have subdomains. We have a wildcard set up that forwards to our app servers, we have scripts that create the vhost file and tap Apache to restart, and no proxies need to be modified to allow /foo/bar/baz to go to server1.foo.com.
When I managed a handful of apps, subfolders were nice Everything under www was great for SEO and everything else. But the fact is that users don't care about URLs, our sites on subdomains get found by search engines because we link to them, and if we need to move foobarapp to another more powerful box (or to the cloud) it's WAY easier.
I hate this even more for sites like GitHub pages, which use http://name.github.com/project/ for the pages and http://github.com/name/project/ for the repo. Trying to rewrite the URL to get from one to the other is an exercise in fiddly copypasting.
It's frustrating but could be solved regardless or sub-domain/sub-directory preference.
I do not believe this is a good argument for or against subdomains, though.
YMMV.
One thing that I don't get now, or at least I'll have to work for it, is sharding my setup, when I get to that point. Before I figured I could just move people to app1.apprabbit.com, app2.apprabbit.com, etc, but now I will have to handle the redirecting in my configs when I get to the point where I need to split things out for performance. On the other hand, this makes it that much easier to move a big customer off of a shared host and give them their own server without changing anything public facing.
In the end it definitely has it's perks and drawbacks, but I wanted subdomains, and so far I haven't had any problems with them.
For one project of mine, I'm keeping my images on a separate domain so I can switch to a different system for hosting images... For instance, host them on a single-threaded web server or move them to S3/CloudFront.
Similarly, if a project involves different technology than the main site or if it may involve different technology in the future, that's a good reason for a subdomain. If you might want to host it differently, that's a good reason for a subdomain.
I don't know what to tell you about S.E.O.; a few years ago there were some people who made subdomains by the hundred because they thought they got S.E.O. advantages from that -- S.E.'s like keywords in the domain. My understanding is that keywords in subdomains used to be unreasonably powerful, people exploited them, and now there's not so great. S.E.'s also appear to have depth limits on the crawls they do a single host, so multiple hosts might also be a way to get more pages indexed. On the other hand, there are powerful ways to get monolithic sites indexed too. Other people think it's better to put all your eggs in one basket so you can get a higher score on one host.
The truth is that people outside the S.E.'s don't know what the real rules are, and the S.E.'s will change them next year.
- blog.domain.com is easier to manage (easier to use third party service, easier to keep code updates separate, ...).
- everything user-generated that you have little control over (for example, forums or blogs with badly moderated comment section) goes to subdomains.
- everything you control goes to subfolders.
Thus, if you can keep your blog free of spam, it should go to subfolder.
So, you could use domain.com for your projects, and point blog.domain.com to a hosted service (Posterous?)
Over the last 2 years, every big organization switched to folders (it used to be mail.google.com and finance.google.com, and now it's www.google.com/mail and www.google.com/finance; the only google exception I'm aware of is news.google.com). I remember reading an article about that having something to do with ease of geobalancing or something.
http://particletree.com/notebook/subdomains-development-suck...
Unless you want to run bind of course