Is it possible to set a different alias based on whether a cookie is present? What I am trying to achieve is: use a different folder to display different content based on whether a cookie has been set in my browser, whilst keeping all the URL paths the same. Something like:

if(COOKIE=foo & value=val)
  alias /x /y
  alias /x /z

Any suggestions welcome

Thank you kindly! Jason


Try using something like this:

RewriteEngine on
RewriteCond %{HTTP_COOKIE} ***
RewriteRule /x(.*) /y$1 [L]
RewriteRule /x(.*) /z$1 [L]

Replace *** with the correct thing you want to match - see How do I make RewriteCond %{HTTP_COOKIE} match a cookie value exactly?

  • This is exactly what i was looking for. Thank you very much – jbwt Jun 12 '15 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.