Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to use redirection to secure certain pages on my site.  The
theory is to check to see if a user is "logged in" at the top of a
page, and if not, redirect them to a login page.

A typical web page will look like this:

<!--#include virtual="secure.php"-->
    <p>Secure Content Here</p>

The secure.php file looks like this:


  $schema = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http';

  // Check to see if the user is logged in.
  if (! isset($_SESSION["userid"]))
    header("Location: " . $schema .


This all works fine in ASP.  In PHP, however, I can't seem to get the
redirect to work.  If I just type the secure.php URL directly into the
browser's address bar, it will redirect properly.  If I call the page
I want to secure (either with a .html or a .php extension), it just
seems to ignore the redirect.

Any idea why?

Re: Redirection

On 19 Jul 2004 09:09:44 -0700, (Bryan)

Quoted text here. Click to load it

If the page you want to secure is a .php, you need only use:



David ( )

Re: Redirection

Quoted text here. Click to load it

That was the issue.  It was a .html page, not a .php page.  ASP (or
more accurately, IIS) will allow you to do this, but apparently PHP
and/or Apache won't.

I ended up figuring out exactly what you suggested, and it worked.

Thanks for the response.


Site Timeline