Basic Authentication Using .htaccess In Wamp/Xampp Server
This is how we create a basic authentication using .htaccess file in windows. The use case is when you provide a simple api to your client. This will secure the url with user and password using basic auth. Accessing the path and any files below url user must authenticate first. http://localhost/secure/ Following the steps below we will have the .htaccess and .htpasswd inside \secure folder. This folder is in your local web server 1. Create the .htaccess file in folder that you want to secure (in this example secure/ folder). The .htaccess file should contain the 4 lines below AuthType Basic AuthName "Restricted Content" AuthUserFile D:/wamp/www/secure/.htpasswd Require valid-user 2. To create the .htpasswd file, using command line locate the bin directory ( where htpasswd.exe is located ) in the active version of apache ( D:\wamp\bin\apache\apache2.0.63\bin ). Run htpasswd -c D:\wamp\www\secure\.htpasswd user should look like ...