I have two domains both pointing to /var/www:
www.example.com: main domain, has cookiesstatic.example.com: cookie-less domain for static content
I now want to free the static.example.com domain from cookies using .htaccess using following lines:
RequestHeader unset Cookie
Header unset Set-Cookie
My problem:
Since both domains share one .htaccess file: How do I make sure these lines only apply to static.example.com?
You have several options. Let me show some in order of my preference:
1) create dedicated folder for each domain, your server serves. Then you can also configure each in different way.
2) set cookies correctly. Browser will append cookies only to requests for correct domain – so don’t set cookie domain
example.combut usewww.example.comand do domain name normalization of your requests – so redirect permanently all requests tohttp://example.comtohttp://www.example.com3) unset specific cookie using
mod_rewriteusing theCOswitch. For more details see this question.