[Mongrel] Apache Re-Write and Directories

Philip Hallstrom mongrel at philip.pjkh.com
Tue Oct 3 11:53:27 EDT 2006


> I am using the 'default' Apache 2.2 mod_rewrite rules suggested from the Web
> site and they are working.
>
> One thing related to static (non cluster directed) resources:
>
> If I have a directory in public called 'static', if I request it as follows:
>
> http://www.domain.com/static/  - then it works
>
> If I request it as:
>
> http://www.domain.com/static - then it does not work as it gets directed to
> the cluster.
>
> How can I change my rewrite rules to have both of the above URLs be served
> by the static resource via Apache, not by Mongrel?

Add this to the beginning...

   RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} -d
   RewriteRule ^(.+[^/])$ $1/ [R]



>
> Rewrite rules:
>
>  RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
>  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
>  RewriteRule ^.*$ /maintenance.html [L]
>  # Rewrite index to check for static index.html
>  RewriteRule ^/$ /index.html [QSA]
>  # Rewrite to check for Rails cached pages with .html extentions
>  RewriteRule ^([^.]+)$ $1.html [QSA]
>  # All dynamic requests get sent to the cluster
>  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
>  RewriteRule ^/(.*)$ balancer://cluster%{REQUEST_URI} [P,QSA,L]
>
> Thanks!!!
>
> Hunter
>
>
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>


More information about the Mongrel-users mailing list