如果 特定页面 请求包含 特定引用 ,是否可以通过 Apache 删除 特定 cookie ?
我发现了一个类似的问题,它是关于一般删除 cookie ( How to remove a cookie in Apache ) 但这不使用任何条件或 cookie 名称。
我的具体用例是:如果请求的 url 是“/choose-language”并且引用者是“www.external.domain”,则删除(或取消设置它的值)名为“country”的 cookie。
目前有以下 Apache 模块可用:
core mod_so mod_watchdog http_core mod_log_config mod_logio
mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic
mod_authn_core mod_authn_file mod_authz_core mod_authz_host
mod_authz_user mod_autoindex mod_deflate mod_dir mod_env mod_expires
mod_filter mod_headers mod_mime prefork mod_negotiation mod_php7
mod_proxy mod_proxy_fcgi mod_remoteip mod_rewrite mod_setenvif
mod_socache_shmcb mod_ssl mod_status
最佳答案
您加载的模块意味着 Apache 2.4,您可以在其中访问 <If>
和 Header
上的条件表达式
<If "%{HTTP_REFERER} =~ /www.external.domain/ && %{REQUEST_URI} == '/choose-language'">
Header add Set-Cookie country=
</If>
或者
Header add Set-Cookie country= "expr=%{HTTP_REFERER} =~ /www.external.domain/ && %{REQUEST_URI} == '/choose-language'"
关于apache - 根据url和referrer删除cookie,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49648010/