How to change cookie name using mod_rewrite?

I try to change the name of the cookie set by AWB ELB, but keep its value with the rewrite condition and rewrite the rule.

Here is what I managed:

RewriteCond %{HTTP_COOKIE} AWSELB=(^BD.*) [NC]
RewriteRule ^(.*) - [CO=SIMELB:%1:.amazonaws.com:lifetime:-1]

Obviously RewriteRulewrong, but can anyone help me with the correct syntax?

+1
source share
2 answers

Instead of rewriting the cookie name, I tested it with mod_header directives and seemed to address my Amazon ELB gambling gambling app issue with another Amazon ELB.

RequestHeader edit Cookie AWSELB SIMELB
RequestHeader edit Cookie APPELB AWSELB
Header always edit Set-Cookie AWSELB APPELB
Header edit Set-Cookie AWSELB APPELB

, , , , , AWSELB , "set-Cookie" AWSELB, APPELB = {} cookie , AWSELB.

+1

, , , . , - (^BD.*), , , - ^. (BD[^;]+), ; ( , ).

cookie, INVALID, .

Apache mod_rewrite Cookies

RewriteCond %{HTTP_COOKIE} AWSELB=(BD[^&]+) [NC]
# Delete the old one
RewriteRule ^ - [CO=AWSELM:INVALID:.amazonaws.com:0:/:-1]
# Add the new one
# Specify your lifetime in minutes or 0 for the browser session (60 below)...
# ALso add the path
# Assumimg the -1 is for insecure cookies
RewriteRule ^ - [CO=SIMELB:%1:.amazonaws.com:60:/:-1]

cookie , , , AWS. cookie, , , .

, BD... AWSELB=([^;]+), .

:

, , RewriteCond RewriteRule. RewriteCond. , , , , .

# no capture group the first time since you don't use it until later
RewriteCond %{HTTP_COOKIE} AWSELB=BD.+ [NC]
RewriteRule ^ - [CO=AWSELM:INVALID:.amazonaws.com:0:/:-1]
# This will continue to execute since the previous didn't have [L]
RewriteCond %{HTTP_COOKIE} AWSELB=(BD[^&]+) [NC]
RewriteRule ^ - [CO=SIMELB:%1:.amazonaws.com:60:/:-1]

(: cookie, HTTP-, script Apache, cookie )

+2

Source: https://habr.com/ru/post/1621056/


All Articles