I have a phpBB install in app/public/forums. If I visit mydomain.com/forums/index.php, all is well (since static files are looked up before Rails takes over). However, mydomain.com/forums does not work, because routes takes over and it doesn''t know about a "controller" named forums. So my question is: Can I specify a route to static content? I want to tell Rails that anything that sites under forums/ should do an autolookup for forums/index.php. For example: mydomain.com/forums -> mydomain.com/forums/index.php mydomain.com/forums/admin -> mydomain.com/forums/admin/index.php etc, etc. Or is this better accomplished using rewrite rules in .htaccess before we hit dispatch.fcgi?
On 7/14/05, Belorion <belorion-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> etc, etc. Or is this better accomplished using rewrite rules in > .htaccess before we hit dispatch.fcgi?I would say you''d want to do this in .htaccess file (or lighttpd configuration). Even using FastCGI there''s no reason to incur the extra cost of overhead of calling into the Rails framework. Rails is extremely powerful and easy to use, but that power doesn''t come for free performance-wise. Save some clock cycles by doing this before it ever his the framework. Cheers, bs.
Ben Schumacher wrote:> On 7/14/05, Belorion <belorion-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>etc, etc. Or is this better accomplished using rewrite rules in >>.htaccess before we hit dispatch.fcgi? > > > I would say you''d want to do this in .htaccess file (or lighttpd > configuration). Even using FastCGI there''s no reason to incur the > extra cost of overhead of calling into the Rails framework. Rails is > extremely powerful and easy to use, but that power doesn''t come for > free performance-wise. Save some clock cycles by doing this before it > ever his the framework.Does anyone have an example of this? My rewrite mojo is failing. I thought this should work RewriteRule ^/contact/$ /contact/index.html [QSA,L] RewriteRule ^/contact$ /contact/index.html [QSA,L] but it does not, nor can I assemble any working variation. Calling example.com/contact/index.html directly works fine, but omitting the index.html part gives a routing exception. Thanks, James
James Britt wrote:> Ben Schumacher wrote: > >> On 7/14/05, Belorion >> <belorion-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> etc, etc. Or is this better accomplished using rewrite rules in >>> .htaccess before we hit dispatch.fcgi? >> >> >> >> I would say you''d want to do this in .htaccess file (or lighttpd >> configuration). Even using FastCGI there''s no reason to incur the >> extra cost of overhead of calling into the Rails framework. Rails is >> extremely powerful and easy to use, but that power doesn''t come for >> free performance-wise. Save some clock cycles by doing this before it >> ever his the framework. > > > > Does anyone have an example of this? My rewrite mojo is failing. > > I thought this should work > > RewriteRule ^/contact/$ /contact/index.html [QSA,L] > RewriteRule ^/contact$ /contact/index.html [QSA,L] > > but it does not, nor can I assemble any working variation.Here is what I got to work RewriteRule ^contact$ contact/index.html RewriteRule ^contact/$ contact/index.html Note that the default .htaccess file includes this rule: RewriteRule ^([^.]+)$ $1.html [QSA] When it came before my static rewrites, things broke. Moving it below my static file rewrite rules fixed it. James
I have a question similar to this. Let''s say that I had some static html files that I wanted to wrap with my site layout and have rails serve. Is there a way that I can do this? The driver for this is I have an intranet site where we want our users to have the ability to modify some static content. I have gone the route of creating a "static" controller and having it serve the rhtml files in the views\static folder. The problem with this method is that it has a flat structure. If they want to have items in sub-folders then this method breaks. On 7/14/05, Belorion <belorion-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a phpBB install in app/public/forums. If I visit > mydomain.com/forums/index.php <http://mydomain.com/forums/index.php>, all > is well (since static files are > looked up before Rails takes over). However, mydomain.com/forums<http://mydomain.com/forums>does > not work, because routes takes over and it doesn''t know about a > "controller" named forums. > > So my question is: Can I specify a route to static content? I want to > tell Rails that anything that sites under forums/ should do an > autolookup for forums/index.php. > > For example: > > mydomain.com/forums <http://mydomain.com/forums> -> > mydomain.com/forums/index.php <http://mydomain.com/forums/index.php> > mydomain.com/forums/admin <http://mydomain.com/forums/admin> -> > mydomain.com/forums/admin/index.php<http://mydomain.com/forums/admin/index.php> > > etc, etc. Or is this better accomplished using rewrite rules in > .htaccess before we hit dispatch.fcgi? > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails