NOTE: This is an old article. Please go to the Meshlium development section in order to get the latest tutorials.

Howto control access to web pages with htaccess

Requeriments:

  • At least one Meshlium.

Meshlium has an Apache web server that can be used to display user sites. The user can protect the sites with htaccess configuration. This howto will show some examples to protect files or directories.


Protect a directory with .htaccess. Just create a file to store users and passwords, the file is created by htpasswd.
~$ htpasswd -c .htpasswd tavi
New password:
Re-type new password:
Adding password for user tavi
~$ cat .htpasswd
tavi:7I6fJ0HHbrqe.
~$ vi .htaccess
AuthUserFile .htpasswd
AuthName "Authorized_Name"
AuthType Basic
Require valid-user


Protect only a file with .htaccess. Just create a file to store users and passwords, the file is created by htpasswd.

~$ htpasswd -c .htpasswd tavi
New password:
Re-type new password:
Adding password for user tavi
~$ cat .htpasswd
tavi:7I6fJ0HHbrqe.
~$ vi .htaccess
AuthName "Authorized_Name"
AuthType Basic
AuthUserFile .htpasswd
AuthGroupFile /dev/null
<Files this.file>
require valid-user
</Files>


This is just a small introduction of htaccess. To know more or use it in production enviroments you should check all the configuration capabilities of htaccess.



© Libelium Comunicaciones Distribuidas S.L.

| Terms of use