title: PHP localhost redirection problems
body: <p>This is my first question on SO, I hope I'm doing it right.  I'm new to PHP/MySQL programming.  I've just recently set up a local development environment with WAMP and it is more or less working (at least, I get the green icon, the WAMP php info screen, phpMyAdmin works, and some of my .php files work properly, pulling .css and .inc.php files from the appropriate directories.)</p>
  
  <p>Where I'm having trouble is with php redirect with header().</p>
  
  <p>I've tried many different options, some gleaned from here, but none work.  I'm getting an error "The requested URL /localhost/home.php was not found on this server."</p>
  
  <p>Also, in the location bar of the browser I get:  localhost/localhost/home.php, but I've no idea why.</p>
  
  <p>Here's one version of the snippet from the calling program (index.php), part of which I got from an answer here on SO:</p>
  
  <pre><code>if (isset($_SESSION['Authenticated'])) {
      $host  = $_SERVER['HTTP_HOST'];
      $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
      $extra = 'home.php';
      header("Location: http://$host$uri/$extra");
      exit;
      }
  </code></pre>
  
  <p>Original version, also not working, was:</p>
  
  <pre><code>if (!isset($_SESSION['Authenticated'])) {
      $redirect = 'home.php';
      header("Location: $redirect");
      exit;
      }
  </code></pre>
  
  <p>I've also tried numerous values for the $redirect variable in the original version, including various versions of the path, to no avail.</p>
  
  <p>As far as my setup goes, here is some info you might find useful:</p>
  
  <p>WAMP server version 2.2
  Apache version 2.2.22
  PHP version 5.4.3
  MySQL version 5.5.24</p>
  
  <pre><code>Relevant line from C:\Windows\System32\Drivers\hosts
  127.0.0.1           bke.local       #BKE Test Environment
  </code></pre>
  
  <p>I'm using the default C:\wamp\www as the DocumentRoot</p>
  
  <pre><code>Relevant lines from C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf:
  # DocumentRoot: The directory out of which you will serve your
  # documents. By default, all requests are taken from this directory, but
  # symbolic links and aliases may be used to point to other locations.
  #
  DocumentRoot "c:/wamp/www/"
  .
  .
  .
  # Local access to the Apache HTTP Server Manual
  #Include conf/extra/httpd-manual.conf
  
  
  Relevant lines from C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd.vhosts.conf:
  # Use name-based virtual hosting.
  NameVirtualHost *:80
  #####NameVirtualHost 127.0.0.1:80
  # VirtualHost example:
  # Almost any Apache directive may go into a VirtualHost container.
  # The first VirtualHost section is used for all requests that do not
  # match a ServerName or ServerAlias in any &lt;VirtualHost&gt; block.
  #
  &lt;VirtualHost *:80&gt;
      ServerAdmin webmaster@dummy-host.example.com
      DocumentRoot "c:/apache2/docs/dummy-host.example.com"
      ServerName dummy-host.example.com
      ServerAlias www.dummy-host.example.com
      ErrorLog "logs/dummy-host.example.com-error.log"
      CustomLog "logs/dummy-host.example.com-access.log" common
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerAdmin webmaster@dummy-host2.example.com
      DocumentRoot "c:/apache2/docs/dummy-host2.example.com"
      ServerName dummy-host2.example.com
      ErrorLog "logs/dummy-host2.example.com-error.log"
      CustomLog "logs/dummy-host2.example.com-access.log" common
  &lt;/VirtualHost&gt;
  
  #&lt;Directory C:/Dev&gt;
  #   Order Deny,Allow
  #   Allow from all
  #&lt;/Directory&gt;
  </code></pre>
  
  <p>Current locations of my files:
  .php files into C:\wamp\www
  .css files into C:\wamp\www\styles
  .inc.php files into C:\wamp\www\includes</p>
  
  <p>Before I realized I had this problem, I tried to set up multiple virtual hosts using info from a number of websites (all of which said the same thing), but was unable to make that work at all, so I eliminated my changes and went with the WAMP default.  I suspct the problems are related but can't solve either of them.</p>