How to create password protected web page and files with htaccess
In this post we will give you information about How to create password protected web page and files with htaccess. Hear we will give you detail about How to create password protected web page and files with htaccessAnd how to use it also give you demo for it if it is necessary.
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.
Try this..
Label :
.htaccess
Apache
Web Development
Hope this code and post will helped you for implement How to create password protected web page and files with htaccess. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs