Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Why does it not work?

edited June 2007 in Vanilla 1.0 Help
I want to warn people that a directory is being modified and re-direct them to another page, telling them to come back later.

I'm doing this by putting a file called "locked_y.txt" in the directory then checking with this...

<?php $filename = "locked_y.txt"; if (file_exists($filename)) { header("Location: otherpage.php"); exit; } else { exit; } ?>

Why do I get this error...
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Posted: Thursday, 31 May 2007 at 3:01PM


  • lechlech Chicagoland
    Is "otherpage.php" residing within the same directory in question? Off the top of my head, I believe that the header location best works when you give it an actual address rather than a file which is relative to the current location. The only other reason for weirdness being experienced is funky rewrite rules which are either going full circle or recursing.
  • Yes thanks lech, the file is there in the same directory.
    I don't see what is so different but this now works...
    <?php $filename = 'locked_y.txt'; if (file_exists($filename)) { header("Location: otherpage.php"); exit; } else { echo""; }

    Is there a better way to tell PHP do do nothing besides echo ""?

    Posted: Thursday, 31 May 2007 at 4:33PM

  • lechlech Chicagoland
    I guess that depends how you're using this snippet, if it's a stand-alone script you could do a simple return else flush/clean before you exit();
  • edited May 2007
    The redirect value must be a full url.
  • I don't think so, it works as it is.
    If I enter a full URL it tells me it does not have the permissions to access it, or words to that effect.

    Posted: Thursday, 31 May 2007 at 8:59PM

  • I think it should:
  • Don't want to totally derail this discussion but Lech I've got a question. Is Lech pronounced like "letch" or "lech" with a "ck" sound?
  • lechlech Chicagoland
    I think you asked me this a while ago when you first joined up, Krak. With the "ck" like in "deck" just drop the D for an L. My nephews call me Lex (super man + bald uncle = do the math) and that's an acceptable alternative compared to the other butchered pronunciations I've heard since memory has served me :)

    But yes, that's my name.

    @ Wanderer: Did you get it working? Dinoboff is pretty much right that the header response should be a full URL, unless you're attempting an absolute path on the file system which would obviously be saying you can't access it otherwise it would just say "404 - oops". Unless of course you're actually wanting an inclusion and not a redirect/refresh. See
  • KrakKrak New
    edited June 2007
    lol I probably did. I'll wait another year or two and ask again.
  • Yes I got it working.
    The problem was not the file not being found, it was some sort of recursion according to the error messages from both Firefox and Safari.

    I used a relative path because the function was an include and referred to a file of the same name but different directories, depending on where it was called from.

    Posted: Saturday, 2 June 2007 at 3:46PM

This discussion has been closed.