Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda