# How to protect directory in Mongrel

**URL:** <https://www.ruby-forum.com/t/how-to-protect-directory-in-mongrel/114954>\
**Category:** Rails\
**Created:** [September 19, 2007, 8:15am UTC](https://www.ruby-forum.com/t/how-to-protect-directory-in-mongrel/114954 "2007-09-19T08:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mongdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e0b2c6/32.png) [@Mongdar](https://www.ruby-forum.com/u/Mongdar)\
**Post date:** [September 19, 2007, 8:15am UTC](https://www.ruby-forum.com/t/how-to-protect-directory-in-mongrel/114954/1 "2007-09-19T08:15:43Z")

</div>

Hi Rails Gurus,

I just noticed that mongrel does not process .htaccess.  
How can I password protect a directory in mongrel then?  
I’ve search everyone and cannot find an answer. Please help!!!

---

<div class="post-metadata">

**Author:** ![Mongdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e0b2c6/32.png) [@Mongdar](https://www.ruby-forum.com/u/Mongdar)\
**Post date:** [September 19, 2007, 10:15am UTC](https://www.ruby-forum.com/t/how-to-protect-directory-in-mongrel/114954/2 "2007-09-19T10:15:07Z")

</div>

Mongdar wrote:

> Hi Rails Gurus,
> 
> I just noticed that mongrel does not process .htaccess.  
> How can I password protect a directory in mongrel then?  
> I’ve search everyone and cannot find an answer. Please help!!!

I don’t believe you can.

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![Mongdar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e0b2c6/32.png) [@Mongdar](https://www.ruby-forum.com/u/Mongdar)\
**Post date:** [September 19, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/how-to-protect-directory-in-mongrel/114954/3 "2007-09-19T16:17:30Z")

</div>

On 19 Sep 2007, at 08:15, Mongdar wrote:

> I just noticed that mongrel does not process .htaccess.  
> How can I password protect a directory in mongrel then?  
> I’ve search everyone and cannot find an answer. Please help!!!

You can’t do it so easily.

You have a few options:

- Put Apache in front of mongrel and password protect the directory  
using Apache
- Make a controller in Rails with the same name as your directory to  
protect (if it’s in the /public/ folder) and deny access that way
- If the chance that they’ll guess the name of the files is almost  
non-existant, you can just put an index.html file in the folder
- If you want a dialog box to pop up for login into your app,  
restful\_authentication has some example code on how to handle this  
(it uses it for authenticated XML requests)

Best regards

Peter De Berdt
