如何在此 .htaccess 行中加入 __Secure 前綴?

如何在此 .htaccess 行中加入 __Secure 前綴?

抱歉,我不是 Apache 專家。

我需要__Secure為此 htaccess 行添加前綴:

Header onsuccess edit Set-Cookie (.*) "$1; SameSite=Strict; Secure"

這可能嗎?如何?

答案1

原始回覆

這是否為您提供了所需的資訊:

https://geekflare.com/httponly-secure-cookie-apache/

Apache中的實作過程

  • 確保您已mod_headers.so在 Apache HTTP 伺服器中啟用

  • 新增以下條目httpd.conf

    Header always edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
    
  • 重啟Apache HTTP伺服器進行測試

更新 2022-12-21 @ 20:58GMT

指導site 指示的格式為Set-Cookie: __Secure-ID=123; Secure; Domain=example.com; HttpOnly

還關注MDN語法,從你的例子來看,我希望你需要:

Header onsuccess edit Set-Cookie (.*) "__Secure-$1; SameSite=Strict; Secure"

; HttpOnly您可能還想在最後添加強文字。

Header onsuccess edit Set-Cookie (.*) "__Secure-$1; SameSite=Strict; Secure; HttpOnly"

相關內容