password protect my domain, but not my subdomains

Discussion in 'Apache' started by chris-T33, Nov 12, 2006.

  1. #1
    chris-T33, Nov 12, 2006 IP
  2. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Add a password protection to your default index page in the root directory, that will be enough to avoid people see www.example.com, but being able to go through subdirectories.

    To protect the page use include along with any simply password protection code, or pasting something as simple as this:

    
    <?php
    $infologin           ="Restricted Access";
    $loginname           ="CHANGEME";  // your desired username
    $password            ="CHANGEME";    // your desired password 
    
    if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $loginname) && ( $PHP_AUTH_PW == "$password" )) ) {
    	header("WWW-Authenticate: Basic enter=$infologin");
    	header("HTTP/1.0 401 Unauthorized");
    	error("Access Denied");
    	}
    ?>
    
    Code (markup):
     
    Pat Gael, Nov 12, 2006 IP
  3. chris-T33

    chris-T33 Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i've try this and it's not working :(


    i put an user & pass and i cannot access it.


    i want to use it on a phpBB board :(
     
    chris-T33, Nov 12, 2006 IP
  4. thuonghieu

    thuonghieu Peon

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thuonghieu, Dec 3, 2006 IP