So here's a weird one for you guys:
I have a program that needs an environment variable (normally set in .htaccess or httpd.conf) to render content.
If I sent CONTENT=A then it renders one set of content, CONTENT=B renders another set of content. Right now I've simply got the variable set using SetEnv set to CONTENT=A.
I'm looking for an elegant solution to switch between content sets based on:
1. Location (aka mod_geoip)
2. User initiated action (user clicking on link - like /contenta or /contentb which would just fire rewrites/redirects)
Obviously serving content based on location would be the normal case but once the user initiated action happens I would not want to override that action unless the user switches back.
I'm looking at doing this in apache for portability and for ease of upgrade.
Essentially, these are the steps I'm thinking of implementing:
1. Check for presence of cookie with CONTENTA or CONTENTB variable set using mod_rewrite HTTP_COOKIE conditional. If that cookie is set, insert appropriate environment variable using mod_rewrite. (I'm pretty sure I can set environment variables as part of a substitution; does anyone know for sure?)
2. If no cookie is set, check location via mod_geoip, set cookie through mod_headers, and loop back through #1. (do this so mod_geoip only fires on session initiation)
3. If user clicks requests "switcher" link /contenta or /contentb, set the appropriate cookie through mod_headers, set the environment variables, and redirect the user back to the page where they came from (can you use REFERRER variables in substitution rules like that?)
Does that make sense? Am I missing something? I want to do all of this in mod_rewrite so I can use conditionals