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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 519k
  • Answers 519k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer if it's already in the database you could do a… May 16, 2026 at 8:31 pm
  • Editorial Team
    Editorial Team added an answer Unless you're using code weaving, this can't work. The default… May 16, 2026 at 8:31 pm
  • Editorial Team
    Editorial Team added an answer Nevermind. For anyone stuck with the same issue, it can… May 16, 2026 at 8:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have found following question: $0 (Program Name) in Java? Discover main class? but
I am building a framework where I need error checking for classes. I cannot
Well, I have a really small problem. How can I access an ASP.NET Drop
I have a web application deployed in an internet hosting provider. This web application
I want to be able create stored procedures using phpMyAdmin and later on use
It is convenient for me to use a set. I like how I can
It might seem natural to use Ctrl + + , Ctrl + - ,
Is there anything else that the code must do to sanitize identifiers (table, view,
I was having problems getting a null layout manager working, and I found this
Here goes my .htaccess file's content. Options +FollowSymLinks RewriteEngine On RewriteRule ^online-products$ products.php?type=online RewriteRule

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.