Eliminate leading-directory name from URL's

Hello,

Is there a way to get Rails to ignore a leading-directory in a URL (either in the environment.rb or routes.rb file)?

For example, I'd like all requests to: http://domain.com/blah/products to get processed as [app]/products

I don't have access to use mod_redirect, and right now Rails keeps looking at "blah" to be a controller. I'd simply like it always stripped out of the URL.

Any suggestions? Thank you!

-Jason

that's not a leading directory, it's the rails routing path which follows the convention :controller/:action/:id. Say you were to strip out the controller portion and all you have are actions, which controller will these actions execute in? And what if you have two controllers with the same name, how will rails disambiguate between the two actions. Or say you wanted to get rid of the action name and just have a controller name? Then what action should be called?

If you want to use the format:

myapp.com/products (shows index page) myapp.com/products/1 (shows details for product with id 1) myapp.com/products/1/edit (shows edit screen for product with id 1)

then look into using restful routes.

Mike

Thanks for your reply!

Perhaps I wasn't clear.

The web server is prefixing all Rails-bound requests with /blah, and it provides no additional information to the app.

So, myapp.com/products/1/edit would COME IN to rails as myapp.com/blah/ products/1/edit

I'd like to eliminate that leading directory ("blah", in the above example)

Thanks, -Jason

(Rails keeps trying to interpret the "blah" as a controller, when in fact it should be ignored)

Jason Crystal wrote:

Hello,

Is there a way to get Rails to ignore a leading-directory in a URL (either in the environment.rb or routes.rb file)?

Any suggestions? Thank you!

-Jason

in your config/routes.rb

map.connect 'blah/:controller/:action/:id'

hth

ilan