RyanUK
RyanUK

Reputation: 67

Password protecting a single page using .htaccess and .htpasswd

Ok so I want to protect a single webpage using .htaccess and .htpasswd

I have successfully implemented this to work on my index.php page but if I go any deeper it doesn't work.

I'm using codeigniter and here is the code from my .htaccess file

    # password-protect single file
    <Files "vAdmin.php">
    AuthName "site"
    AuthType Basic
    AuthUserFile /home/bg33qn/public_html/ci/application/views/.htpasswd
    require valid-user
    </Files>

I have both the .htaccess file and the .htpasswd file saved in:

    /home/bg33qn/public_html/ci/application/views/

Using this to protect the index page at the following location works fine:

    /home/bg33qn/public_html/ci/

Any suggestions?

Thanks

Upvotes: 2

Views: 5975

Answers (1)

user2738336
user2738336

Reputation:

Do you want to password protect just one file?

<FilesMatch "vAdmin.php">
AuthName "Member Only"
AuthType Basic
AuthUserFile /home/bg33qn/public_html/ci/application/views/.htpasswd
require valid-user
</FilesMatch>

Just a tip: I hope you don't use this tool as the only security process protecting that page. It seems that page has something to do with administrators.

Updated: Create this .htaccess file where vAdmin.php is stored. So in your case, /home/bg33qn/public_html/ci/application/views/.

Upvotes: 2

Related Questions