# Exposing directories in rails app

**URL:** <https://www.ruby-forum.com/t/exposing-directories-in-rails-app/89707>\
**Category:** Rails\
**Created:** [March 22, 2007, 7:12am UTC](https://www.ruby-forum.com/t/exposing-directories-in-rails-app/89707 "2007-03-22T07:12:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveybaby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@steveybaby](https://www.ruby-forum.com/u/steveybaby)\
**Post date:** [March 22, 2007, 7:12am UTC](https://www.ruby-forum.com/t/exposing-directories-in-rails-app/89707/1 "2007-03-22T07:12:29Z")

</div>

Hi,

Is it possible to expose a directory within a rails app where the  
standard rails routing is not applied?

ie [example.com/](http://example.com/) and [example.com/foo](http://example.com/foo) would use the standard rails routes  
defined in routes.rb, but [example.com/bar](http://example.com/bar) would return a standard  
non-rails-parsed directory listing similar to  
[Index of /pub](http://www.ibiblio.org/pub/).

Is there some special :ignore flag I can set on select directories in  
routes.rb?

---

<div class="post-metadata">

**Author:** ![steveybaby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@steveybaby](https://www.ruby-forum.com/u/steveybaby)\
**Post date:** [March 22, 2007, 9:25am UTC](https://www.ruby-forum.com/t/exposing-directories-in-rails-app/89707/2 "2007-03-22T09:25:56Z")

</div>

That wouldn’t be a rails setting… you’d need to configure your web  
server to not send requests for that path to rails at all. Then it’s  
just plain ol’ web-serving. I think most servers render directory  
listings if there is no “default” file in there (index.html, etc.).

b

---

<div class="post-metadata">

**Author:** ![steveybaby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@steveybaby](https://www.ruby-forum.com/u/steveybaby)\
**Post date:** [March 22, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/exposing-directories-in-rails-app/89707/3 "2007-03-22T15:30:06Z")

</div>

Ben M. wrote:

> That wouldn’t be a rails setting… you’d need to configure your web  
> …

Of course! I open up public/.htaccess and there on line 5:

# If you don’t want Rails to look in certain directories,

# use the following rewrite rules so that Apache won’t rewrite certain

requests

# 

# Example:

# RewriteCond %{REQUEST\_URI} ^/notrails.\*

# RewriteRule .\* - [L]

I’ve been looking in the wrong place this whole time. Thanks so much for  
the pointer.

Steve Hulet
