Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
How to password protect Laravel site within apache vhost?

I am trying to password protected my Laravel application with Apache vhost file. It asks for my username and password but it keeps asking this for every route and every time I reload the page.

Can somebody please explain me how do I need to change the config file in order for the site to ask password and username only once?

This is the directory part of my vhost file:

    ServerAdmin admin@mysite.com
    ServerName staging.app.mysite.ee
    ServerAlias www.staging.app.mysite.ee
    DocumentRoot /var/www/mysite/app/staging/public

    <Directory "/var/www/mysite/app/staging">
            Options +FollowSymLinks +MultiViews +Indexes
            AllowOverride All
            Order allow,deny
            Allow from all

            #AuthType Basic
            #AuthName "Restricted Area"
            #AuthUserFile /var/www/.htpasswd
            #Require valid-user
    </Directory>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can put below code in either .htaccess file in document root of your project. Or you can add below code in apache configuration file.

AuthName "Dialog prompt"
AuthType Basic
AuthUserFile FULL_PATH_OF_FILE_HTPASSWD
Require valid-user

.htpasswd file should contain username and password.

Username:HASHED_PASSWORD

This will prompt password only once ie. will be set in session.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!