.htaccess security


Password Protect

Besides the use of URL rewriting and redirecting. We could use plain old .htaccess file to lock down a specific folder for a handful of selected users using the following snippet.

Note that the .htpasswd file contains the credentials needed to gain access to the site. This file content is in the form

Where the password is hashed and the hash can be obtained with the following command

For example

Block Access

To block access from certain IP address

To block access from certain user agent (namely bots)


Leave a Reply