skip to Main Content

I am trying to set up HTTP basic auth for the Laravel app in apache vhost but it is not working.

It keeps asking for a password after each request made

This is my current vhost content for the site and at the moment it is not doing anything. Any help is appreciated

ServerAdmin [email protected]
ServerName demo.my-site.com
ServerAlias www.my-site.com
DocumentRoot /var/www/demos/my-site/client/public

<Directory "/var/www/demos/my-site/client">
    Options +FollowSymLinks +MultiViews +Indexes
    AllowOverride All
    Order allow,deny
    Allow from all

    AuthType Basic
    AuthName "Protected Area! Please login!"
    AuthUserFile /var/www/.htpasswd
    Require valid-user
</Directory>

2

Answers


  1. You need to handle it through .htaccess in your root folder. Remove the .. from the vhost.

    RewriteCond %{HTTP:Authorization} ^(.+)$
    RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    Login or Signup to reply.
  2. The simplest way to do:

    Put your project into a xampp > your_project,
    browse localhost/your_project.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search