Parajsa.com


Parajsa Shqiptare Forum

Cfare ju duhet te dini?

 

Kthehuni Mbrapa   Parajsa Shqiptare Forum | Albanian Paradise | Webmaster

How do I password protect a directory using .htaccess?

Pergjigju
 
LinkBack Alternativa Teme Vleresoni Temen
  #1  
Te vjeter 06-04-2008, 18:28
Minifotoja e anetarit Administratori
Parajsa Shqiptare
 
Reg: 06-07-02
Lokalizimi: London
Postime: 1,967
Images: 2351
Faqe ne Ditar: 2
How do I password protect a directory using .htaccess?

You can establish password protection using the following two files: .htaccess and .htpasswd. Please have in mind that you can use these files only of you have a Unix-based hosting plan.

The directory password protection is a four step process:
First, you’ll need to create an .htpasswd file to store the log-in information for the protected directory.

Second, you’ll need to upload your .htpasswd file to the directory that you are going to protect.

Third, you’ll need to create an .htaccess file to instruct the server to password protect the directory.

Finally, you’ll need to upload your .htaccess file to the directory you’re going to protect.

I. Creating the .htpasswd file:
Open up a text editor on your computer. We recommend that you use Notepad (Windows), SimpleText (Macintosh), or Emacs (Linux / UNIX).
Save the file as .htpasswd (including the initial dot).

Now, make sure that your text editor did not append a .txt suffix to the file name. (In Windows, you can do this by right-clicking the icon for the text file and selecting “Properties”.) If the file name does have a .txt suffix (i.e. ‘.htpasswd.txt’), remove the suffix by renaming the file.

Before entering code into your new file, make sure that “Word Wrap” is turned off. (In Notepad, select “Format…” from the top navigation bar and make sure that “Word Wrap” is unchecked).

Begin adding users by selecting the username that you will use to login to the protected directory. (Usernames can be between 2 and 16 characters long and should only contain lower-case letters and numbers.)
Type the username into the .htpasswd file followed by a colon. At this point, your .passwd file should look like this (“username” is used as example):
username:

Now, you have to encrypt the password that you will use to login to the directory.
To do this, visit http://users.abac.com/cgi-bin/pass.pl. On this page, enter your password (up to 13 characters) and hit the Encrypt button – the encrypted password will be displayed on the following page.

Important: The encrypted password will always be 13 characters long, regardless of the actual length of your password.

Copy the encrypted password from the webpage and paste it into your .htpasswd file following the colon. Be sure to remove any spaces that may precede or follow the password. Your file should look like this:

username:WvePMzyciLRIo

To add additional users, end the current line with a carriage return and repeat steps (5) through above on the next line.
When you’re done adding users, save the file.

II. Uploading the .htpasswd file:
Open your FTP client and establish a connection to your web space using your FTP Username and FTP Password.
Browse to the directory that you’d like to protect.
Set your upload settings to ASCII. (Uploading .htpasswd files in ‘binary’ format may have unexpected consequences.)
Upload your .htpasswd file from your local computer.
After the upload is completed, you may need to change the file permissions for the .htpasswd file. They should be set to 644 or RW-R--R--.

III. Creating the .htaccess file:
Using the same text editor that you used to create the .htpasswd file, create (and save) a new file called .htaccess. (Be sure to remove the .txt suffix, if your software automatically appends one.)

Add the following code to the .htaccess file:

AuthUserFile path
AuthName “Enter Password”
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

Replace path above with the absolute path to the directory you have uploaded the .htpasswd to:
How can I find out the absolute path to my Unix-based shared hosting account?

Example: If your account is on partition u5, and your main FTP username is aplus, and you are going to protect the html/images/ directory, then you have to replace path in the .htaccess file with the following line:
/home/u5/aplus/html/images/.htpasswd

You can also replace “Enter Password” in the .htaccess file with a message you want to be displayed to your website visitors when prompted for the login information (please make sure to keep the quotes).

Save the .htaccess file on your local computer.

IV. Uploading the .htaccess file:
Once again, open up an FTP connection to your web space.
Browse to the directory that you would like to password protect.
Using an ASCII connection, upload your .htaccess file to the same directory you have uploaded the .htpasswd file.

After the upload is completed, you may need to change the file permissions for the .htaccess file. They should be set to 644 (using chmod) or RW-R--R--.

That’s it! If your implementation was successful, visitors to the password protected directory will now have to enter the username and password you have specified in the .htpasswd file before being allowed access.

Important: If you have a Windows-based hosting plan, you cannot use .htaccess files.

Thanks to Andrew Hickl, Aplus.Net Knowledge Base Support
__________________
The heaven's sound is composed inside your heart, listen to its beat to syncronize your life onto the angel's steps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Live!Google!Sphinn!Stumbleupon!Yahoo!Spurl this Post!Reddit! Wong this Post!
Pergjigjuni me Citim
Pergjigju

Bookmarks

Alternativa Teme
Vleresojeni kete Teme
Vleresojeni kete Teme:

Rregullore Postimi
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is aktivizuar
Buzeqeshjet jane te aktivizuar
Kodi [IMG] eshte i aktivizuar
Kodi HTML eshte i dizaktivizuar
Trackbacks are aktivizuar
Pingbacks are aktivizuar
Refbacks are aktivizuar


Te gjitha oret jane ne GMT +1. Ora tani eshte 22:05.




Parajsa Shqiptare