Browser asks for password several times .htaccess using subdomain

I have a private homepage and I want to password-protect it using .htaccess. This is what my .htaccess file looks like:

AuthName MySite
AuthType Basic
AuthUserFile /what/ever/.htpasswd
require valid-user

#making embeded videos work in wordpress
<Files ~ ".(mp4|m4v)">
AddType video/mp4 .mp4 .m4v
order allow,deny
allow from all
satisfy any

# Code for WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /whatever/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /whatever/index.php [L]
#End WordPress

Options -Indexes

It’s located in the folder directory directed for the homepage.

Problem is that when accessing the server via it’s subdomain the browser keeps asking for login/pass. If pressing cancel after two atempts one is directed to the page anyway.

If trying to access the webpage without subdomain, like this:, the browser asks for password once and then it’s done. No problems.

This is the homepages .conf file in apache:

<VirtualHost *:80>

ServerAdmin [email protected]
DocumentRoot /var/www/html/site
AccessFileName .htaccess

<Directory "/var/www/html/site">
AllowOverride All
Order allow,deny
Allow from all
Require all granted

         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined


Ask Ubuntu Asked by Ginger Server on December 8, 2021

1 Answers

One Answer

Apache got confused with too many requests for passwords from different places.

By only using this code:

<Directory "/var/www/html/folder/">
    AuthUserFile  /home/user/.htpasswd
    AuthName  "Pass"
    AuthType Basic
    require user username

In 000-default.conf solved the problem.

I thought every .conf file needed it's own directions for password. They don't.

Answered by Ginger Server on December 8, 2021

Add your own answers!

Related Questions

Driver for new Canon ink-tank printers?

1  Asked on February 17, 2021 by 2cv67


How can I monitor the TBW on my Samsung SSD?

5  Asked on February 16, 2021 by youreagitfornotusinggit


Unable to install Angular CLI

1  Asked on February 16, 2021


makefile shows error in g++ how to solve it

1  Asked on February 15, 2021


PCSX not loading after new game start

2  Asked on February 15, 2021 by lumbeast


having trouble setting $PATH

1  Asked on February 14, 2021 by band


Installing lubuntu 14.04 alternate with wubi

2  Asked on February 13, 2021 by user244791


Same android SDK for Multiple Users

1  Asked on February 13, 2021 by dulara-malindu


Some sort of boot menu, possibly the gnu menu

0  Asked on February 12, 2021 by linus


How To Create a Bootable Clone of boot disk

2  Asked on February 12, 2021 by theold-crab


2 different SSH connections on 2 different port

0  Asked on February 12, 2021 by marcco-piolat


Ask a Question

Get help from others!

© 2022 All rights reserved.