I would like to add an "X-Slogan" header to Apache's responses set to a value chosen at random from a list of strings. The best solution I've been able to come up with so far is to rotate through the strings based on TIME_SEC, e.g.
UnsetEnv HEAD_X_SLOGAN_1
UnsetEnv HEAD_X_SLOGAN_2
UnsetEnv HEAD_X_SLOGAN_3
UnsetEnv HEAD_X_SLOGAN_4
RewriteCond %{TIME_SEC} <15
RewriteRule . - [env=HEAD_X_SLOGAN_1:%{TIME_SEC},last]
RewriteCond %{TIME_SEC} >14
RewriteCond %{TIME_SEC} <30
RewriteRule . - [env=HEAD_X_SLOGAN_2:%{TIME_SEC},last]
RewriteCond %{TIME_SEC} >29
RewriteCond %{TIME_SEC} <45
RewriteRule . - [env=HEAD_X_SLOGAN_3:%{TIME_SEC},last]
RewriteCond %{TIME_SEC} >44
RewriteRule . - [env=HEAD_X_SLOGAN_4:%{TIME_SEC},last]
Header set X-Slogan "Palm trees" env=HEAD_X_SLOGAN_1
Header set X-Slogan "Oranges" env=HEAD_X_SLOGAN_2
Header set X-Slogan "Shoes" env=HEAD_X_SLOGAN_3
Header set X-Slogan "Velociraptors" env=HEAD_X_SLOGAN_4
However, this isn't really random. Is there a better way to do this?
mod_rewrite has a MapType of rnd which may be able to do what you want.
See this page under randomized plain text.
Thanks to Dennis I arrived at the following solution:
Apache config:
slogans.txt: