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 currently trying to get my head around in understanding how to set-up a "cookieless" domain using WHM / Cpanel - unfortunately without any success at this moment.

I have a Magento store and I would like to use "cookieless domains" for my media, skin (template) and js files. Magento has a nice feature to define URL for those folders.

My current setup is as follows:

  • www.mydomain.com <- main store
  • media.mydomain.com <- subdomain to the media folder (mydomain.com/media/)
  • skin.mydomain.com <- subdomain to the media folder (mydomain.com/skin/)
  • js.mydomain.com <- subdomain to the media folder (mydomain.com/js/)

I think it's poinless to have them used as "cookieliess domains" since my Magento installation uses .mydomain.com as cookie domain, so what I would like to achieve is to register a new additional domain and have it point via WHM / cPanel to those specific locations. I have tried to change the A and CNAME records although without any success as they were just simply redirecting from one page to another in the browser (newdomain.com -> jump to old.com). What kind of records do I have to set to have this working properly?

Some advice would be highly appreciated.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

It sounds like you are taking the guidance of Yslow with a little too much importance. The performance difference at the end of this endeavour will be completely negligible, your bottleneck is Magento, not any static content it serves. Your time would be better spend either

a) Finding a new specialised Magento web host OR b) Learning a wealth of information on LAMP tuning

The former being strongly advised

That being said, you have a much more straightforward option of removing the cookie on an element before returning it to the user, this is commonly done on Varnish, but can equally be achieved with Apache.

<FilesMatch "\.(html|htm|js|css|gif|jpeg|png|pdf|txt|zip|7z|gz|jar|war|tar|ear|java|pac)$">
  <IfModule header_module>
  Header unset Cookie
  </IfModule>
</FilesMatch>

But bear in mind, you'll then have the caveat that if any piece of content listed above causes a 404 Error, the Magento index.php default bootstrap will be loaded in place of the content and as such will have the cookie stripped - thus causing instant session loss for the end user. So be extra cautious to make sure there are no 404's on static content OR use a combination of SetEnvIf, rewrite conditions and rewrite rules to ensure it can't happen.

But again, I would stress, your efforts really will be in vain - the performance difference will be nil.

--

Although, to answer your question, setting up another domain is as simple as adding a parked domain in cPanel, pointing the A record(s), of said domain, to the same IP as the main website itself - then ensuring you don't have any .htaccess rewrite logic forcing the domain to be 301/302'ed to the primary store domain.

share|improve this answer
    
Thank you very much sonassi for your extensive answer! –  Patrick Lanfranco Jun 24 '12 at 3:29
    
Then click accept ... –  sonassi Jun 24 '12 at 8:59
add comment

Your Answer

 
discard

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

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