Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I found out that you cannot use a RewriteCond backreference as a pattern condition in the next Rewrite Cond...

UPDATE: As it turns out, mod_rewrite doesn't expand any variables in the test pattern, so I am effectively only testing for the existence of the cookie... Any ideas on how to actually test the value instead of just 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

share|improve this question

1 Answer 1

I'd comment instead if I had the rep...

I don't think you need the backslash you have in your examples. E.g.

RewriteCond %{HTTP_COOKIE} niftyExpire\=([^; ]+) [NC]

should just be

RewriteCond %{HTTP_COOKIE} niftyExpire=([^; ]+) [NC]

There a great resource here with some examples (not specifically about dates, but including rewrite rules based on a cookie's value):

http://www.askapache.com/htaccess/htaccess-fresh.html

share|improve this answer
    
Thanks, I had found that, unfortunately it's not working for me.... right now, I have: RewriteCond %{HTTP_COOKIE} niftyExpire\=([^; ]+) [NC] RewriteCond %{TIME} < %1 [NC] RewriteRule ^.*$ /passed.html [R=302,L,NC] which is outputting this in the error log: [Thu Jul 08 17:39:30 2010] [alert] [client 189.58.20.117] /home/niftypre/public_html/.htaccess: RewriteCond: bad flag delimiters [Thu Jul 08 17:39:30 2010] [alert] [client 189.58.20.117] /home/niftypre/public_html/.htaccess: RewriteCond: bad flag delimiters –  Eric Jul 8 '10 at 22:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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