I want to be able to rewrite my URL's to a single level URL. This means that i need to make a dynamic(will change in each language) rewrite rule, like this:
Original Url: http://www.mydomain.com/account/pages/13
I always want to show the URL in a single level:
http://www.mydomain.com/my-page-title
never no more than one slash / after the domain name.
I also need to be able to translate the page title in the above example:
http://www.mydomain.com/my-translated-page
How do I achieve this, and it should be able to change this on runtime - that is to "improve" the url, just like rewrite rules in htaccess
You have to create your own Routes
. As you are using the MVC4
put this custom route above the Default Route of the Application.
routes.MapRoute(
name: "Custom_Route",
url: "My-Page-Title/{id}",
defaults: new { controller = "Home", action = "About", id = UrlParameter.Optional }
);
And for translating a Url in Mvc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With