Solved

Protecting certain folder in a virtual host

Posted on 2004-04-14
3
369 Views
Last Modified: 2013-11-18
I run an apache web server, utilizing named virtual  host.
I want to password protect a subfolder in the virtual host, for example this folder :

http://www.mydomain.com/tmp/

I know that I should use .htacess, but how to put this into httpd.conf ?

Here is part of my httpd.conf configuration:

DocumentRoot "/var/www/html"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "/var/www/html">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny
    Allow from all

</Directory>

<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
    DocumentRoot /home/www/mydomain.com/html/
    ScriptAlias /cgi-bin/ /home/www/mydomain.com/cgi-bin/
    ServerName mars.mydomain.com
    ErrorLog /home/www/mydomain.com/logs/mydomain.com-error_log
    CustomLog /home/www/mydomain.com/logs/mydomain.com-access_log common
    CustomLog /home/www/mydomain.com/logs/mydomain.com-deflate_log deflate
</VirtualHost>
0
Comment
Question by:kapot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
shaggyb earned 160 total points
ID: 10821604
first youll need this in the first part of the config

<Directory "path to the root of your web page">

    Options Indexes FollowSymLinks


    AllowOverride authConfig   <------------------ need that....this lets you override to allow access to lower directorys  or ask for passwords  what ever


    Order allow,deny
    Allow from all
</Directory>



then

AccessFileName .htaccess

then

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

to hide the .htaccess file in the given directory if you have indexing on



then


Alias /youralias in your expaple avoe this would be tmp "path to the directory you want to be tmp localy on your hdd example c:/windws"

<Directory "path to your dir same as what is in the quiote above">

    Options Indexes MultiViews FollowSymLinks  <-------------- the indexes is only if you want someone to be able to see the idiviual files
    AllowOverride AuthConfig     <----------- make apache look for the htaccess file
    Order allow,deny
    Allow from all

</Directory>

0
 
LVL 3

Expert Comment

by:shaggyb
ID: 10821608
damn...sorry for the typos     i need to goto sleep
0
 
LVL 15

Expert Comment

by:samri
ID: 10822983
hi Kapot,

Shaggyb is pretty much on the track.

For more information, you may want to jump to Apache website for some information, and HOWTO on how to get that achived.

http://httpd.apache.org/docs-2.0/howto/auth.html
http://httpd.apache.org/docs-2.0/howto/htaccess.html

Hope this would help.

cheers
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question