rhavin
rhavin

Reputation: 1687

How do I set a catch-remaining default route to a directory?

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*.

Upvotes: 2

Views: 98

Answers (1)

rohit89
rohit89

Reputation: 5773

Try this:

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

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

Upvotes: 1

Related Questions