Jump to content

Password Protect A Page With Cp?


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...