Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 239001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:33:02+00:00 2026-05-11T20:33:02+00:00

I was wondering if protecting a web directory with an .htaccess file (with the

  • 0

I was wondering if protecting a web directory with an .htaccess file (with the .htpasswd file outside the public apache webroot) is a secure way to protect a directory (and its contents).

Could someone explain the Do’s and Don’ts of this kind of protection?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:33:02+00:00Added an answer on May 11, 2026 at 8:33 pm

    The authentication will be passed unprotected over the net if you use the standard http protocol. This is not regarded as safe, as someone could sniff the password.

    If you restrict acces to https it is quite safe. This would mean to install and enable the apache module for ssl encrypted http traffic (port 433, https:// in the adress line of the browser) and disable the standard http traffic for this directory on port 80. Username and Password will be ssl encrypted. Be sure to select a good password (long and complex enough, not possible to guess or brute force).

    Apache configuration can be tricky, so take a lot of care to keep it simple and test against possible mistakes.

    It can be a good idea to move the access restriction configuration from the .htaccess file to the main apache configuration file if you have knowledge and control of it. Could also be easier for you to keep it in the .htacces file. And “easy” can be safer. Do it the way it feels simple and safe and easy to maintain and remember for you.

    This is a simple setup to enhance security and protect against accidents:

    If you have php and email configured on the machine where the protected directory is you can write a simple alarm script. Just a php file “alarm.php” with a single line with the php mail function that sends you an e-mail, telling you that htaccess protection does not work.

    If your domain and directory path is “http://mybox.example.com/secretdir/alarm.php” you can enter this in a browser on a different machine and you should get that mail as long as htaccess is “opened”. If it is protected you can enter the username and password and you will also get the mail.

    To make an automated alarm out of this you could use a different unix box that tries to get this url every 15 minutes or so. The line for the crontab:

    */15 * * * * user1 wget http://mybox.example.com/secretdir/alarm.php

    user1 is a user on this machine who is allowed to run wget, and wget must be installed.

    You can disable the htaccess protection as a test and should get the mail every 15 minutes.

    From my experience it is a common security flaw that a directory that you think is protected looses its protection when you change something and you are not aware, this way you get the email that warns you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if there's a way to write-protect every page in a Linux process'
Wondering what the best / good way of doing this would be in jQuery.
Wondering if there is any way to get the lambda expressions that result from
Wondering if anyone can suggest a good file replication tool that will replicate across
Wondering if there is a good way to generate temporary URLs that expire in
I'm wondering if there's any way to populate a dictionary such that you have
wondering if there is a way to do the following: I basically want to
Wondering if its possible to communication from javascript to flash without the use of
Wondering if any of you can help me: I've made a signup modal that
Wondering if someone could please explain the difference between these two queries and advise

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.