Solved

Protecting certain folder in a virtual host

Posted on 2004-04-14
3
362 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
  • 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now