简体   繁体   中英

Allow an Apache directory listing from a subdirectory of rails “public/”?

I'd like to enable Apache directory listings on a specific subdirectory of my Rails application's "public/" directory. For the sake of this discussion, let's say it is the "public/listme"

I've set Apache options to enable directory listings, but if I request something like http://mydomain.com/listme , I get a 404 error, and if I check the Rails log, I get an error like:

ActionController::RoutingError (No route matches "/listme")

So: is there a way to disable routing for a specific folder within my Rails app and allow Apache's automatic directory listings to kick in?

It turns out that this question is answered in the modrails documentation. See http://www.modrails.com/documentation/Users%20guide%20Apache.html

In summary :

Suppose that you have a Rails application in /apps/foo. Suppose that you've dropped Wordpress — a blogging application written in PHP — in /apps/foo/public/wordpress. You can then configure Phusion Passenger as follows:

<VirtualHost *:80>
    ServerName www.foo.com
    DocumentRoot /apps/foo/public
    <Directory /apps/foo/public/wordpress>
        PassengerEnabled off
        AllowOverride all      # <-- Makes Wordpress's .htaccess file work.
    </Directory>
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM