0
votes

I'm using MVC and having trouble figuring out how to hide the controller and action in the URL. I have seen many things on how to hide the controller or the action but most are not for the default controller. My controller looks like this:

routes.MapRoute("Default", "{controller}/{action}/{id}", new{ controller = "Home", action = "Index", id = UrlParameter.Optional });

When you navigate to my site the URL looks like this:

www.mysite.com/Home/Index

I need it to hide the "Home" and "Index" so it looks like this:

www.mysite.com

I have the default route as the last route in the routeConfig file. Any help would be appreciated.

1

1 Answers

0
votes

Is this your root URL. If so than use the following code in your routes.rb file.

root "home#index"

then you will get the www.mysite.com

However, there are many techniques to hide the controller and action from the url. Please have a look on this post rails remove controller path from the url