Deployment Routing Issue

Hi folks,

I used Cap to deploy my first Rails app on Friday, but every time I
try getting to the pages, I'm getting a 404 error. In my
production.log, I keep getting an error message similar to this: "no
route found to match "/.html" with {:method=>:get}" It's doing this
for everything.

Everything works fine on my development machine.

Any suggestions?

We'll need some more info Pete.

Like web server, app server. Did you use Deprec (or some other tool) to setup your box? mongrel? fastcgi?

- sounds a bit like you have an apache url rewrite problem.

give some more symptoms.


Sorry about that ....

Web server is Apache 2.0.2 -- can't upgrade to 2.2 just yet. App is
being served by Mongrel.

Here's what I have in the Apache configuration:

              # Set the domain

              # Set the DocumentRoot, this is where apache will look
for static files

              # This is the public directory of your rails application

              # As previously stated, my app is deployed with
Capistrano, so I set DocumentRoot to the current/public directory

              DocumentRoot /var/www/vhosts/

              # Set where you want apache put its logs

              # note I use deflate as log format, this is because I
use mod_deflate to compress all outputs

/var/www/vhosts/ combined

              ErrorLog /var/www/vhosts/

              # if you want to have server-wide statistics,

              # you can also tell apache to log in a common file
shared by all your domains

              # CustomLog /var/log/apache2/access.log deflate

              # ErrorLog /var/log/apache2/error.log

              # I use utf-8 for all my projects, so I force apache to
send the good charset by default.

              # This is needed if you use page caching and want apache
serves these with the good charset.

              # AddDefaultCharset utf-8

              # Allow limited access to your public directory

              # dont allow user to list directories

              # allow apache to FollowSymlinks

              <Directory /var/www/vhosts/>

                Options -Indexes FollowSymLinks

                AllowOverride All

                Order allow,deny

                Allow from all


              # Be sure mod_rewrite is activated for you vhost

              RewriteEngine On

              # If you use applications which resides in cgi-bin, like awstats

              # the following mod_rewrite RewriteRule will allow
apache to know it should not proxy these request and the PT switch
will allow the ScriptAlias directive to work

              # RewriteRule "^/cgi-bin/.*" "$0" [QSA,PT,L]

              # RewriteRule "^/awstatsicon/.*" "$0" [PT,L]

              # Set a ScriptAlias for /cgi-bin/ url

              # All url begining with /cgi-bin/ will be served from
the specified cgi-bin deirectory

              #ScriptAlias /cgi-bin/ /var/www/mydomain.tld/cgi-bin/

              #<Directory /var/www/mydomain.tld/cgi-bin/>

              # AllowOverride All

              # Options ExecCGI FollowSymLinks

              # Order allow,deny

              # Allow from all


             # Do not allow open proxying, allow only requests starting with a /

             <LocationMatch "^[^/]">

                Deny from all


             # Avoid open you server to proxying

             ProxyRequests Off

             # Let apache correctly rewrite redirect

             ProxyPassReverse / http://localhost:8000/

             # Let apache pass the original host not the ProxyPass one

             ProxyPreserveHost On

             # As I mentioned earlier, Capistrano disable_web task
allows you to disable your application

             # In fact it only create a simple page named
maintenance.html in the directory public/system/ of your application

             # The following mod_rewrite rules will tell apache to
directly serve the maintenance.html pages if it find it out.

             RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f

             RewriteCond %{SCRIPT_FILENAME} !maintenance.html

             RewriteRule ^.*$ /system/maintenance.html [L]

             # For static files it's good to avoid hitting your mongrel process

             # so let apache knows it should serve it directly

             # for a rails application it means, files in images /
stylesheets / javascripts

             RewriteRule "^/(images|stylesheets|javascripts)/?(.*)" "$0" [L]

             # Try to match a cached pages

             RewriteRule ^([^.]+)$ $1.html [QSA]

             # if the cached page does not exists

             RewriteCond %{REQUEST_FILENAME} !-f

             # proxy requests to your mongrel instance

             RewriteRule "^/(.*)" "http://localhost:8001/$1" [P,QSA,L]

Hey Pete - my apache-fu (especially rewrites) is weak, but from a scan it looks like you've deployed mongrel to 2 ports (8000, 8001). Is this intentional?

ProxyPassReverse / http://localhost:8000/

then a rewrite rule for:

RewriteRule "^/(.*)" "http://localhost:8001/$1" [P,QSA,L]

that looks a little fishy.

If that's not it, then I would kill your rewrite rules wholesale, verify it's working, then add them back slowly.

I'd give you my apache2 config, but I bet it's too different to be useful.