문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top