1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Absolutely stumped as to why SetEnvIf not working??

Discussion in 'Apache' started by carlos123, Sep 14, 2009.

  1. #1
    Hi everyone,

    I am absolutely stumped as to why SetEnvIf is not working to set an environment variable that I can then access in PHP through the $_ENV array.

    Inside my .htaccess file I have this...

    SetEnvIfNoCase Referer "^http://domain.com/default" locally_linked=1

    The above line should create an ENV variable called "locally_linked" and set it to value of 1 but it does no such thing.

    I have tried all kinds of combinations and nothing. Absolutely nothing ever shows up.

    It's the only line in my .htaccess file other than RewriteEngine on (but I've commented out all rewrite rules).

    Any ideas as to how I can get this to work.
    The setenvif whatever module is loaded.

    carlos123, Sep 14, 2009 IP
  2. rathin

    rathin Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    what webserver are you useing?
    rathin, Sep 15, 2009 IP
  3. carlos123

    carlos123 Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    I am using Apache 2 something.

    Running locally on my Linux computer.

    The following work just fine...well..as far as I can tell.

    # Works...SPECIAL_PATH found in PHP $_SERVER array.
    SetEnv SPECIAL_PATH /foo/bin

    # Works...locally_linked found in PHP $_SERVER array.
    SetEnvIfNoCase Referer "^$" locally_linked=1

    # Also works but nvalinks ends up being REDIRECT_navlinks.
    SetEnvIf Request_URI "/my-rates" navlinks=lessons

    The following doesn't work yet...

    SetEnvIf Request_URI "/index.php?content=default" locally_linked=2

    In other words when I access the site using http://www.domain.com/index.php?content=default, nothing happens.

    The other thing is the ENV variables that are created are all prefixed with "REDIRECT_"....don't know why.

    Any additional input you might have on these mysterious would be greatly appreciated.

    I have spent hours on this and am still mystified as to why it works sometimes, how it works, and why it doesn't at other times.

    carlos123, Sep 15, 2009 IP