Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 924241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:19:13+00:00 2026-05-15T19:19:13+00:00

I found out that you cannot use a RewriteCond backreference as a pattern condition

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:19:14+00:00Added an answer on May 15, 2026 at 7:19 pm

    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 modified mod_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 .htaccess file, that would lead to an irresponsibly large amount of overhead.

    That being said, for proof of concept, 132 lines of mod_rewrite blasphemy:

    RewriteEngine On
    
    RewriteCond %{HTTP_COOKIE} niftyExpire=([^;\ ]+) [OR]
    RewriteCond fail ^(fail)$
    RewriteRule index.html$ /fail.html [E=niftyExpire:%1,E=RW_TSTATUS:%1]
    
    RewriteCond %{ENV:RW_TSTATUS) !=fail
    RewriteCond %{ENV:niftyExpire} ^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})\d{2}$
    RewriteRule .* - [E=RW_CYEAR:%1,E=RW_CMON:%2,E=RW_CDAY:%3,E=RW_CHOUR:%4,E=RW_CMIN:%5]
    
    # Check if current YY*YMMDDHHMM < cookie YY*YMMDDHHMM
    #(applicable only for this decade..but that's good enough)
    RewriteCond %{TIME_YEAR}%{ENV:RW_CYEAR} !^(\d{4})\1$
    RewriteCond %{TIME_YEAR}%{ENV:RW_CYEAR}  ^\d{2}(\d)\d{3}(\d)\d$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5|[0-5]6|[0-6]7|[0-7]8|[0-8]9)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_YEAR}%{ENV:RW_CYEAR}  ^\d{2}(\d)\d{3}(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYY*MMDDHHMM < cookie YYY*MMDDHHMM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_YEAR}%{ENV:RW_CYEAR} !^(\d{4})\1$
    RewriteCond %{TIME_YEAR}%{ENV:RW_CYEAR}  ^\d{3}(\d)\d{3}(\d)$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5|[0-5]6|[0-6]7|[0-7]8|[0-8]9)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_YEAR}%{ENV:RW_CYEAR}  ^\d{3}(\d)\d{3}(\d)$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYY*MDDHHMM < cookie YYYY*MDDHHMM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MON}%{ENV:RW_CMON}   !^(\d{2})\1$
    RewriteCond %{TIME_MON}%{ENV:RW_CMON}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 ^01$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MON}%{ENV:RW_CMON}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYM*DDHHMM < cookie YYYYM*DDHHMM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MON}%{ENV:RW_CMON}   !^(\d{2})\1$
    RewriteCond %{TIME_MON}%{ENV:RW_CMON}    ^\d(\d)\d(\d)$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5|[0-5]6|[0-6]7|[0-7]8|[0-8]9)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MON}%{ENV:RW_CMON}    ^\d(\d)\d(\d)$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYMM*DHHMM < cookie YYYYMM*DHHMM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_DAY}%{ENV:RW_CDAY}   !^(\d{2})\1$
    RewriteCond %{TIME_DAY}%{ENV:RW_CDAY}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_DAY}%{ENV:RW_CDAY}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYMMD*HHMM < cookie YYYYMMD*HHMM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_DAY}%{ENV:RW_CDAY}   !^(\d{2})\1$
    RewriteCond %{TIME_DAY}%{ENV:RW_CDAY}    ^\d(\d)\d(\d)$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5|[0-5]6|[0-6]7|[0-7]8|[0-8]9)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_DAY}%{ENV:RW_CDAY}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYMMDD*HMM < cookie YYYYMMDD*HMM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_HOUR}%{ENV:RW_CHOUR} !^(\d{2})\1$
    RewriteCond %{TIME_HOUR}%{ENV:RW_CHOUR}  ^(\d)\d(\d)\d$
    RewriteCond %1%2 ^(01|[01]2)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_HOUR}%{ENV:RW_CHOUR}  ^(\d)\d(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYMMDDH*MM < cookie YYYYMMDDH*MM
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_HOUR}%{ENV:RW_CHOUR} !^(\d{2})\1$
    RewriteCond %{TIME_HOUR}%{ENV:RW_CHOUR}  ^\d(\d)\d(\d)$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5|[0-5]6|[0-6]7|[0-7]8|[0-8]9)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_HOUR}%{ENV:RW_CHOUR}  ^(\d)\d(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYMMDDHH*M < cookie YYYYMMDDHH*M
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MIN}%{ENV:RW_CMIN}   !^(\d{2})\1$
    RewriteCond %{TIME_MIN}%{ENV:RW_CMIN}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MIN}%{ENV:RW_CMIN}    ^(\d)\d(\d)\d$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    # Check if current YYYYMMDDHHM* < cookie YYYYMMDDHHM*
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MIN}%{ENV:RW_CMIN}   !^(\d{2})\1$
    RewriteCond %{TIME_MIN}%{ENV:RW_CMIN}    ^\d(\d)\d(\d)$
    RewriteCond %1%2 ^(01|[01]2|[0-2]3|[0-3]4|[0-4]5|[0-5]6|[0-6]7|[0-7]8|[0-8]9)$
    RewriteRule .* - [E=RW_TSTATUS:success]
    
    RewriteCond %{ENV:RW_TSTATUS} !fail|success
    RewriteCond %{TIME_MIN}%{ENV:RW_CMIN}    ^\d(\d)\d(\d)$
    RewriteCond %1%2 !^(\d)\1$
    RewriteRule .* - [E=RW_TSTATUS:fail]
    
    RewriteCond %{ENV:RW_TSTATUS} !=fail
    RewriteRule .* /pass.html
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently found out that no argument constructor and multiple argument constructor cannnot
I found out that I can use a different theme in an C# WPF
I found out that in order to open a Gmail compose screen you'd have
EDIT After some more research I found that I cannot use a continuous form
I was messing around with SDL and found out that you cannot rotate images
I just have found out that there is a function called func_get_arg in PHP
I have found out (in a hard way) that a collection that is being
I found out that it is possible to open the windows explorer with a
I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded
I found out that the FormWizard only __init__ 's once, when the url is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.