.htaccess

From Ilianko

...

При достъп до дадена директория на уеб сървъра, Apache първо проверява за наличие на .htaccess, ако има такъв прочита неговото съдържание. Това позволява да се създават специфични настройки за достъпа на файловете от тази директория.

.htaccess e текстов файл. Може да се създаде с текстов редактор, а после да се запише в съответната директория.

Създавне на защитенa директория с парола

Трябва да се изпълнят няколко стъпки за може Apache да ни иска парола при достъпа до дадена пакпа от web сървъра.

  1. Създаване на потребители и генериране на пароли
  2. Създаване на файл с потребителите и паролите.
  3. Добавяне на няколко параметърна към .htaccess

създаване на потребители и пароли

В файла .htaccess се добавя следната

AuthUserFile /full/path/to/.htpasswd
AuthName "Please Log In"
AuthType Basic


You'll need first to define a few parameters for the .htaccess file. It needs to know where to find certain information, for example a list of valid usernames and passwords. This is a sample of the few lines required in an .htaccess file to begin with, telling it where the usernames and passwords can be found, amongst other things.


You've now defined a few basic parameters for Apache to manage the authorisation process. First, you've defined the location of the .htpasswd file. This is the file that contains all the usernams and encrypted passwords for your site. We'll cover adding information to this file shortly. It's extremely important that you place this file outside of the web root. You should only be able to access it by FTP, not over the web.

настройка на .htaccess