Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am looking for a solution on a LAMP server to keep a site cookieless such as "example.com", where static content is served from "static.example.com", and with rules in place to rewrite requests for "www.example.com" to "example.com". I am really hoping to avoid setting up a cookieless domain for the static content due to an unanswered SEO concern with regards to CNAMEing to a CDN. Is there a way, (or safe hack), that can be implemented where a second domain such as "www.example2.com" is CNAMEd, aliased, or otherwise used with "example.com" to somehow trick a php application into maintaining state with a cookie dropped on "www.example2.com" therefore keeping all of "example.com" cookieless?

If such a solution is feasible, what implications would exists with regards to SSL and cross-browser compatibility other than requiring users to accept cookies from 3rd party domains and possibly needing an additional SSL to keep the cookie secure?

Thanks in advance to all.

share|improve this question

1 Answer 1

You can host your static content anywhere. I recommend setting up a CNAME to your static assets so you can have a nice domain like static.sample.com to reference in your code. Regarding www.example.com and example.com, you should point example.com to your IP and www.example.com is simply a CNAME that points to example.com.

Regarding cookies, I'm not sure I follow your question, but you can set cookies on example.com that will show on any variation of that domain (app1.example.com, static.example.com www.example.com)

Simply prepend the domain name with a period to have the cookie apply to all subdomains: ".example.com"

share|improve this answer
    
thanks for the reply Erik. what i am aiming for is to keep the cookie valid on example.com only and none of it's subdomains. it's a maximizing performance issue where cookies are currently dropping with every static asset. –  jasonspalace Feb 18 '10 at 20:10
    
You should be able to simply set the cookie without the initial period then. However, this will lock it to that domain. You'll need to do a URL re-write to return a 301 and redirect traffic from www.example.com to example.com or vice-versa. You can see the three lines you'll need to add to your .htaccess file here, it maps www.af-design.com to af-design.com: af-design.com/blog/2008/11/12/301-redirects-in-apache –  Erik Giberti Feb 18 '10 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.