How to create password protected web page and files with htaccess

How to create password protected web page and files with htaccess

In this tutorial, I will let you know how to use .htaccess to password protect your web pages in simple steps.

There are so many website that protect their some pages by asking you for a username and password. Without entering valid credentials, you can not see the web pages.

Htaccess is known as most secure method of password protection. Using .htaccess you can protect single webpage or entire directory.

You will need to create two files .htaccess and .htpasswd in the directory that you are going to password protect.

For this example, I create a blog directory in /var/www/html/.

Now run the following command to generate .htpasswd file with username and password.

htpasswd -c .htpasswd your-user-name

.htpasswd file should contain :

user:$apr1$c4Ol904J$SmqVIhw53PGDmaVWM9Vhx.

Now add following line of code in the .htaccess file :

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /var/www/html/blog/.htpasswd
Require valid-user

Now when you run your blog application in the browser it will ask you for username and password.

If your web server does not support htaccess then above steps will not work.

Your htaccess file must be a text file not some other format.

Phone: (+91) 8800417876
Noida, 201301
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort otele gelen escort sapanca escort söğütlü escort taraklı escort
sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort serdivan escort sapanca escort karasu escort hendek escort ankara escort
sakarya escort kızlar sakarya escort kaliteli sakarya escort vip sakarya escort elit sakarya escort bayan sakarya escort adresleri.