I have a running awstats installation and needed a way to protect the cgi-bin statistics with a password. Thanksfully there is a way to achieve that through the Apache. To secure your let’s say awstats.pl or any other /cgi-bin/ executable with a password here is what you need to do:
First make sure you have:
Allowoverride All directive enabled in your Apache Directory permissions for the /cgi-bin/.
Next you will need to create an .htaccess file in your /cgi-bin/ directory .The file should contain something close to:
<FilesMatch "awstats.pl">AuthName "Login Required"
AuthType Basic
AuthUserFile /var/www/awstats/.htpasswd
require valid-user
</FilesMatch>
The above example presumes that you have created the .htpasswd in /var/www/awstats/.
To create this file issue the command:
debian:~# htpasswd -c /var/www/awstats/.htpasswd admin
That’s all now your awstats installation or any other executable specified in FileMatch would be created with a password.
More helpful Articles

Tags: Allowoverride, apache, AuthType, AuthUserFile, awstats, cgi bin directory, command, directive, directory permissions, file, htaccess file, htpasswd, installation, issue, login, lt, password, Password Protecting single file with htaccess password / Securing single exetubale in Apache with password through htaccess, pl, Protecting, quot, Securing, single file, something, statistics, Thanksfully, var, way, www