Search code examples
php.htaccesswamp.htpasswd

.htpasswd path in .htaccess file


My .htpasswd file is in 'www' folder in wamp. My .htaccess file is also in same 'www' folder.I want to set path for .htpasswd in .htaccess file. How to set path in AuthUserFile

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile www/.htpasswd    **path incorrect
AuthGroupFile /dev/null 
require valid-user

Solution

  • You must use the full path to your .htpasswd file.

    Create a .php file in the same folder, containing the following code :

    <?php
    echo dirname(__FILE__) . '/.htpasswd';
    ?>
    

    Then access it via your browser and it should display the full path you'll need to put in your .htaccess file.