I found out that you cannot use a RewriteCond backreference as a pattern condition in the next Rewrite Cond…
What I have looks right, but Tim is correct in the comment bellow… This is still passing when we are beyond the expiration date saved in the cookie.
Any ideas on how to actually test the value instead of the existence?
RewriteCond %{HTTP_COOKIE} niftyExpire=([^;\ ]+)
RewriteRule .*index.html /fake.html [E=niftyExpire:%1,C]
RewriteCond %{TIME} <{ENV:niftyExpire}
RewriteRule .*fake.html /pass.html [R,L]
RewriteRule .*index.html /fail.html [R,L]
Thanks,
-Eric
Alright, so it turns out that you can theoretically make this work. However, and let me stress this very clearly, do not, under any circumstances, do this.
Compared to using a script, using a program-backed
RewriteMap(although not always possible), or in an extreme scenario compiling a modifiedmod_rewrite, I can only imagine that the performance of this is absolutely horrible, and since it has to be prepared on every single request when used in a.htaccessfile, that would lead to an irresponsibly large amount of overhead.That being said, for proof of concept, 132 lines of
mod_rewriteblasphemy:If anyone has an easier way, or could suggest a way this could be simplified even more, I’m all ears. I’ve probably committed a crime against humanity by writing this monstrosity, but at least we can say it isn’t impossible now.