2

Perhaps simply due to lack of good keywords, I wasnt able to find any useful solution for a problem that should be almost trivial…

In my routes.rb, how do I tell: "If no other route matches request, then deliver /foo/bar/request"?

(Note: request ≠ '/')

To be more specific:

If http://example.com/somedir/test/1/2/3 is not matched, try /for/bar/somedir/test/1/2/3, just if that does not exist, deliver *APP_DIR/public/404.html*.

rhavin
  • 1,512
  • 1
  • 12
  • 33
  • 1
    take a look here: http://stackoverflow.com/questions/1447627/basic-rails-404-error-page – Wasi Nov 06 '12 at 15:49
  • 1
    and http://stackoverflow.com/questions/4525715/custom-error-page-ruby-on-rails – Wasi Nov 06 '12 at 15:53
  • Thanx, but i dont want any controller handle it, nor do i want a simple page returned. the request may be – for example – example.com/somewhere/dosomething.pl?a=1&b=2 and i want that delivered from /foo/bar/somewhere/dosomething.pl – rhavin Nov 06 '12 at 16:10
  • Why don't you want a controller handling it? Controllers can dynamically decide where to render from. – histocrat Nov 07 '12 at 18:50

1 Answers1

1

Try this:

match "/home/*request" => redirect{|params| "/foo/bar/#{params[:request]}"}

http://guides.rubyonrails.org/routing.html#route-globbing

rohit89
  • 5,745
  • 2
  • 25
  • 42
  • this would only work if /foo/bar is accesible from the internet – wich it is not (and will not!) /foo/bar is local file system! – rhavin Nov 06 '12 at 17:40
  • I'm not sure that's possible without pointing it to a controller action. – rohit89 Nov 06 '12 at 17:53