On Mar 29, 11:20am, Dan K. [email protected] wrote:
having the catch-all statement, I still get the aforementioned error
pages rather than being re-directed to the home page. Anyone know why
the re-direction is not occurring? Thanks.
I think this is a solution, bear with me for the setup…
I moved an existing static html site to a rails 3 app. I discovered
that I could create a route to catch every static page (e.g.
mysite.com/faq.html). However, that didn’t catch an instance where
someone called mysite.com/faqpage.html (or some other bogus page).
The routes.rb line just above my root :to => “home#index” is this:
match “/:redirect”, :to => “home#index”
In other words, if you put something in the url that doesn’t get
caught by other routes above, then I stick that string into :redirect
and pass it to home#index. That allows me to test for it and do
something. In my case, I use the value to find a content page with a
matching keyword. A little crude, but it lets me manage content via a
model, and if for some reason I delete a page that my old static site
wanted (/faq.html for example) then the rails app doesn’t break. It
just loads “faq” into :redirect and calls “home#index”.
hope that’s helpful