简体   繁体   English

在COOKIE中的.htaccess中设置标题

[英]Set headers in .htaccess from COOKIE

I need to do such thing in htaccess: Check if "auth_key" COOKIE exists (I will set it in frontend part) And then add this value to headers 我需要在htaccess中执行以下操作:检查“ auth_key” COOKIE是否存在(我将在前端部分进行设置),然后将此值添加到标头中

And also my url is also with rewrite rules: 而且我的网址还带有重写规则:

RewriteCond %{REQUEST_URI} ^/api/files/content
RewriteRule api/(.*)$ /server/api/web/$1 [NC,L]

I don't understand how to add to this rule also headers with COOKIE value 我不明白如何向标头中添加带有COOKIE值的标头

Here is a way, you can parse cookie value and set a custom header: 这是一种可以解析cookie值并设置自定义标头的方法:

RewriteEngine On

RewriteCond %{HTTP_COOKIE} (^|\s)auth_key=[^;]+ [NC]
RewriteRule ^ - [E=COOKIE_AUTH_VAL:%1]

Header set Strict-Transport-Security "%{COOKIE_AUTH_VAL}e"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM