Apache HTTP Server
Protect a directory
Suppose the directory to protect is /private.
Create the password file:
$ htpasswd -b -m -c /private/.htpasswd guest qwe123
Create file /private/.htaccess with contents:
AuthType Basic AuthName "Restricted Files" AuthUserFile /private/.htpasswd Require valid-user
Display contents of scripts instead of execute
If you want the .sh, .py, .pl, or .cgi suffixed files to be displayed in the browser as source rather than executed as scripts, simply create a .htaccess file in the directory with contents:
Options +Indexes Options +FollowSymLinks <FilesMatch "(\.(sh|py|pl|cgi))$"> Allow from all RemoveHandler .sh .py .pl .cgi </FilesMatch>
