Gostovanje ::: 037. Zaščita posamezne datoteke z geslom

This is an advanced design tutorial. If you are a beginner, we recommend using the cPanel Password Protect Directory icon. That icon can only protect all the files in a folder, not one specific file.

1. Create a file named .htpasswd and place it above your root so visitors can't access it.
    EXAMPLE: /home/cpanelusername/.htpasswd

2. Put the username and encrypted password inside the .htpasswd file.
    EXAMPLE: john:n5MfEoHOIQkKg

To create the encrypted password you will need to use a utility such as the command-line program htpasswd.
More detailed technical information about htpasswd can be found at 
http://httpd.apache.org/docs/current/programs/htpasswd.html.
It doesn't matter how many files under how many directories you wanted to protect, they can share a common .htpasswd file.

3. Place the following code in your .htaccess file, in the same folder where you want to protect the file.
   (Be sure to replace cpanelusername with your actual cPanel username. Replace test with the path to your file.
   Replace file.html with your file's actual name.)

   EXAMPLE: /home/cpanelusername/public_html/test/.htaccess

   <FilesMatch "file.html">
   AuthName "Member Only"
   AuthType Basic
   AuthUserFile /home/cpanelusername/.htpasswd
   require valid-user

Results:

/home/cpanelusername/public_html/test/file.html is protected.
/home/cpanelusername/public_html/test/index.html and all others are NOT protected.

You can protect more than one file by using wildcard names. On the FilesMatch line, follow one of these examples:

<FilesMatch "*.html">
<FilesMatch "file.*">
<FilesMatch "*.*">

  • 0 uporabniku/om je bi članek v pomoč
Vam je bil odgovor v pomoč?

Povezani članki

Gostovanje ::: 004. cPanel Video podpora

We have set up step-by-step movies on how to do nearly everything with your account. cPanel X3...

Gostovanje ::: 001. Prijava v cPanel

cPanel is used for managing your web hosting account and available on all Linux hosting plans,...

Gostovanje ::: 003. cPanel Priročnik

These are great resources we hope will help: Video Tutorials by cPanelOfficial cPanel User Manual

00. Gostovanje ::: Obvestilo

Članki v tej kategoriji so trenutno na voljo samo v angleškem jeziku. V kolikor imate...

Gostovanje ::: 002. Varna prijava v cPanel

How do I use shared SSL to access cPanel ? Use https and our IP address, followed by the secure...