I am configuring a cookieless domain for all my static content, I see a lot of articles and how-to's use the same document root for as their main domain. Why?

This seems like a disadvantage to me, now their content is indexable two places and they have to use robots.txt or some other means to prevent that.

I use a different document root for my cookieless domain, that only contains the static assets. I redirect www.mycookielessdomain.com and mycookielessdomain.com to my main site, and limit crawling of all thumbnails with robots.txt. Originals can be crawled, not thumbs.

Am I doing it wrong? Does my way of doing have some downside which I am not seeing?

Update: I only redirect direct hits on www.mystatic.com and mystatic.com, not the static assets. But I will remove the redirect and add a simple information page like sstatic.net has.

  • What do you mean by "document root" in this context? And by "redirect", presumably you mean an "external redirect"? If so, that would seem to be defeating the object of having a separate "static" domain?
    – MrWhite
    Feb 14, 2015 at 23:31
  • By document root I mean the base directory for the domain, main domain: /var/www/main, static: /var/www/static. I have a 301 for any direct hits to www.static.com or static.com to mainsite.com. How does this defeat the purpose of the static domain? Any hits on the static files will of course not be redirected. Since the domain has no readable content I figured it might as well redirect somewhere. Feb 14, 2015 at 23:36
  • Yeah, that's what I thought you meant by document root. Although I don't see how the server-side (hidden from public view) document root makes any difference in this case. It's all about HTTP requests. It doesn't matter where the files are actually located. Redirect... yes, providing you're not redirecting the actual hits that should be OK (but that wasn't obvious from your question). Although why redirect anything? You are only serving static content from this domain, so any invalid request should simply result in a 404.
    – MrWhite
    Feb 14, 2015 at 23:53
  • True, I think I'll remove the redirect and just add a simple information page like sstatic.net has. In my mind the two domains should be different, but since I've read a lot of places that they share the document root (making them identical) I though maybe there was something I hadn't thought of; like SEO. Feb 14, 2015 at 23:57
  • To be honest I don't see why they would necessarily suggest using the same document root, but at the same time I don't see how it would matter (SEO or otherwise) - maybe it's just for convenience?! Yes, an entirely different would probably be safest (and possibly a necessity depending on how you are setting cookies). Whether a domain on a different IP address helps I don't know.
    – MrWhite
    Feb 15, 2015 at 0:23

1 Answer 1


In the end I could find no good reason why I should have the same document root on my cookie less domain as my main domain. So I didn't.

What I ended up doing was setting up static.mydomain.com, and use that as the origin for a CDN pull zone; images.mydomain.com. The static domain only serves statics over HTTP to the CDN which serves them to my users over HTTPS, same as the website.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.