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 7533883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:51:25+00:00 2026-05-30T05:51:25+00:00

Why can’t I use mod_rewrite rules similar to this: RewriteEngine On RewriteCond %{ENV:did_rewrite} !=true

  • 0

Why can’t I use mod_rewrite rules similar to this:

RewriteEngine On
RewriteCond %{ENV:did_rewrite} !=true
RewriteCond %{REQUEST_URI} ^(.*)/
RewriteRule (.*) %1/foo.php?original=$1 [E=did_rewrite:true]

To prevent recursion?

When I turn up the RewriteLogLevel, I see:

[.../initial] (3) [perdir /.../test/] strip per-dir prefix: /.../test/stuff -> stuff
[.../initial] (3) [perdir /.../test/] applying pattern '(.*)' to uri 'stuff'
[.../initial] (4) [perdir /.../test/] RewriteCond: input='' pattern='!=true' => matched
[.../initial] (4) [perdir /.../test/] RewriteCond: input='/test/stuff' pattern='(.*)/' => matched
[.../initial] (2) [perdir /.../test/] rewrite 'stuff' -> '/test/foo.php?original=stuff'
[.../initial] (5) setting env variable 'did_rewrite' to 'true'
[.../initial] (3) split uri=/test/foo.php?original=stuff -> uri=/test/foo.php, args=original=stuff
[.../initial] (1) [perdir /.../test/] internal redirect with /test/foo.php [INTERNAL REDIRECT]
[.../initial/redir#1] (3) [perdir /.../test/] strip per-dir prefix: /.../test/foo.php -> foo.php
[.../initial/redir#1] (3) [perdir /.../test/] applying pattern '(.*)' to uri 'foo.php'
[.../initial/redir#1] (4) [perdir /.../test/] RewriteCond: input='' pattern='!=true' => matched
[.../initial/redir#1] (4) [perdir /.../test/] RewriteCond: input='/test/foo.php' pattern='(.*)/' => matched
[.../initial/redir#1] (2) [perdir /.../test/] rewrite 'foo.php' -> '/test/foo.php?original=foo.php'
...

It seems like, on the “recursive” call, the environment variable somehow becomes un-set… But I can’t figure out why that would happen.

To be clear: I know there are a bunch of ways to prevent this kind of recursion. I’d like to understand why this particular way doesn’t work.

  • 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-30T05:51:26+00:00Added an answer on May 30, 2026 at 5:51 am

    I think this blog entry may have your answer. In summary, when Apache performs an internal redirect, it renames all of the environment variables:

    static apr_table_t *rename_original_env(apr_pool_t *p, apr_table_t *t)
    {
        const apr_array_header_t *env_arr = apr_table_elts(t);
        const apr_table_entry_t *elts = (const apr_table_entry_t *) env_arr->elts;
        apr_table_t *new = apr_table_make(p, env_arr->nalloc);
        int i;
    
        for (i = 0; i < env_arr->nelts; ++i) {
            if (!elts[i].key)
                continue;
            apr_table_setn(new, apr_pstrcat(p, "REDIRECT_", elts[i].key, NULL),
                      elts[i].val);
        }
    
        return new;
    }
    

    Unfortunately, this doesn’t seem to be documented anywhere.

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

Sidebar

Related Questions

Can anyone explain me what's going on? I use this method - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
Can anyone explain to me why this program: for(float i = -1; i <
Can I run this in a Windows command prompt like I can run it
Can anybody help me? What should be the datatype for this type -07:00:00 of
Can someone guide me on a possible solution? I don't want to use /bin/cp
can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can't figure out how to do this in a pretty way : I have
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can someone help me with this scenario? *There is a button, which when tapped,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.