MindSlayerSauces Posted April 25, 2006 Share Posted April 25, 2006 I need a little help here. Here’s what I want to do. I have a page, we’ll call it page.php. I want to password protect that page so that when a user clicks on it, is asks for a username & password to view it. I know this can be done to a directory with the control panel under password protect directories. However I can’t move these particular pages as they are part of an oscommerce store. Is there a simple way to do this in the CP? Can it be done? thanks in advance Quote Link to comment Share on other sites More sharing options...
TCH-Andy Posted April 25, 2006 Share Posted April 25, 2006 Hi, You can't protect individual files using cpanel, you would need to edit your .htaccess directly. The simplest way, is to create the complete directory as a a password protected directory in cpanel (then you get the structure and passwords set up in cpanel) then edit your .htaccess file which will contain something like; >AuthName "My Protected file" AuthType Basic AuthUserFile "/home/cpanelusername/.htpasswds/directory/passwd" require valid-user Then modify it to; >AuthName "My Protected file" AuthType Basic AuthUserFile "/home/cpanelusername/.htpasswds/directory/passwd" <Files myprotectedfile.htm> require valid-user </Files> by adding the couple of lines shown above Quote Link to comment Share on other sites More sharing options...
abinidi Posted April 25, 2006 Share Posted April 25, 2006 Wow. Nifty solution. I'm impressed. Quote Link to comment Share on other sites More sharing options...
Samrc Posted April 26, 2006 Share Posted April 26, 2006 Andy, if you add/remove more user name/passwords to that directory, will cPanel overwrite the file and remove that line of code? I know passwords are not kept in the same file and are encrypted, but didn't know if the .htaccess file would be modified too. Quote Link to comment Share on other sites More sharing options...
TCH-Andy Posted April 26, 2006 Share Posted April 26, 2006 If you just add users / passwords then no, it doesn't modify the .htaccess, so you should be fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.