logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache conf <if><else> question whit cookies
Author
TCW



Joined: 14 Dec 2014
Posts: 2
Location: NL

PostPosted: Sun 14 Dec '14 21:26    Post subject: Apache conf <if><else> question whit cookies Reply with quote

Hello all,

I got an question about cookies

in my apache conf i got:
Code:
<Directory  "/atest">
   Header set Set-Cookie "test=nope; path=/;"
</Directory>


So now i got an cookie (woot woot)

now i whant to validate that cookie in another dir
Code:
<Directory "/othertest">
   <If "%{HTTPS} == 'on'">
   <If "%{HTTP_COOKIE} == 'test=nope'">
      Redirect /othertest /sometest
   </If>
      here some digest authn/authz
   </If>
   <Else>
      RewriteEngine On
      RewriteCond %{HTTPS} off
      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
      Require all granted
   </Else>
</Directory>


but i cant seem to validate the &{HTTP_COOKIE} whit some value.. ?

i got apache 2.4.10

if someone could help me out i would be glad.

thanks in advance,

TCW
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 18 Dec '14 12:24    Post subject: Reply with quote

I think it sould be %{cookie}C or ${cookie}C

the docs says

Code:

%{VARNAME}C    The contents of cookie VARNAME in the request sent to the server. Only version 0 cookies are fully supported.
Back to top
TCW



Joined: 14 Dec 2014
Posts: 2
Location: NL

PostPosted: Thu 18 Dec '14 21:46    Post subject: Reply with quote

Hey James,

Thanks for your replay
but the %{Cookie_Name}C is not valid
(or the $)
Code:
Cannot parse condition clause: Variable 'test' does not exist.
 variable ${test} is not defined



i got a workaround....

Code:
SetEnvIf Cookie "test=nope" nope=1
<If "'%{ENV:nope}' == '1'">
   redirect /othertest /sometest
</If>


this works...
but this should be easyer right??

also ting whit:
Code:
'%{ENV:Cookie}' == 'test=nope'

but no luck....

you got anny idee's?
Back to top


Reply to topic   Topic: Apache conf <if><else> question whit cookies View previous topic :: View next topic
Post new topic   Forum Index -> Apache