Serve alternative Apache Directory based on cookie

33 Views Asked by At

I have two distinct folders (htdocs and htdocs2) and I would like to serve files from either the first one or the second one based on the value of a cookie. I tried the following:

 <If "%{HTTP_COOKIE} =~ /frontend=v1/">
   <Directory "/usr/local/apache2/htdocs">
   ..
   </Directory>
 </If>
 <If "%{HTTP_COOKIE} =~ /frontend=v2/">
   <Directory "/usr/local/apache2/htdocs2">
   ..
   </Directory>
 </If>

but the syntax is not valid. Apache says:

<Directory not allowed in <If> context

Is there a valid strategy for achieving my goal?

0

There are 0 best solutions below