Question

I have two domains both pointing to /var/www:

  • www.example.com: main domain, has cookies
  • static.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?

Était-ce utile?

La solution

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.com but use www.example.com and do domain name normalization of your requests - so redirect permanently all requests to http://example.com to http://www.example.com

3) unset specific cookie using mod_rewrite using the CO switch. For more details see this question.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top