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

162
Views
How can I make an area of a website password protected through Apache?

I have been working on this for a while, and I am trying to use .htaccess and .htpasswd. Here is what I have done:

Performed with Apache using Raspberry Pi 3B+ with DietPi installed.

  • I created a new .htpasswd file and proceeded to enter password that I wanted.

  • Next, I redirected to /etc/apache2/sites-enabled/ where I edited 000-default.conf and changed the line of code:

    <VirtualHost *80>
    ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        <Directory "/var/www/etc/"
            AuthType Basic
            AuthName "Restricted Content"
            AuthUserFile /etc/apache2/.htpasswd
            Require valid-user
        </Directory>
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =example.com
        RewriteRule ^https://%{SERVER_NAME%{REQUEST_URI} [END,Ne,R=permanent]
    </VirtualHost>
    

Everything here is the same, except replace "example" with my domain.

This did not affect my site, so I redirected to /etc/apache2/ where I edited apache2.conf and added the line of code:

<Directory /var/www/etc/>
    DirectoryIndex index.php index.html
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

Once again, everything here is the same. etc is the file that I want to password-protect. This made the page that I wanted to protect completely inaccessible, and when I changed AllowOverride and Require all it just made the page completely open. How can I make it so that a password is prompted when you try to access the directory?

over 4 years ago · Santiago Trujillo
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!