Hi,
I created Umbraco Templates for MVC Project.here i have list of categories and based on category i will display the product images.
i will pass the Category Name by using a href tag
from umbraco template to other umbraco templte, by using query string i got the categoryname, from here i called the my action result(i mean controller action by using Html.Action()). total its working fine. like this i was calling
<a href="@childPage.Url?categoryname=@categoryname" >@childPage.Name</a>
If you can't install it, then you can also create rewrite rules in the file /config/urlRewriting.config in Umbraco. In your case the latter would be something like:
Basically, content finders allow you to use custom URL's to find your content. And URL providers ensure Umbraco is aware of what URL's you want to use for a given content node (e.g., when you type Model.Content.Url).
The URL provider might not be as useful in your case if you have only one content node and multiple URL's (though I think it'd probably still work). The content finder would definitely be a good bet.
You may have to tinker with Dan's example rewrite rule before it will work for you. For example, I noticed he has a trailing slash, but your example URL does not have a trailing slash.
Also, Dan is using automatic capture groups (or whatever they are called). Note that you can also used named capture groups to be more explicit. Here is an example UrlRewriting.config file from one of my sites for your reference:
There are a few rules in there you can use to serve as a reference. As an example, the first one ensures that when a user visits ~/en-us/some-page, the server will interpret that URL as ~/some-page?lang=en-us. It will not do a redirect (i.e., the user will always see ~/en-us/some-page)... it's just that the server will see the modified URL.
UrlRewriting
Hi, I created Umbraco Templates for MVC Project.here i have list of categories and based on category i will display the product images.
i will pass the Category Name by using a href tag from umbraco template to other umbraco templte, by using query string i got the categoryname, from here i called the my action result(i mean controller action by using Html.Action()). total its working fine. like this i was calling <a href="@childPage.Url?categoryname=@categoryname" >@childPage.Name</a>
The Problem is I called category Name by using <a href> ,when click category it shows like: (fordon is my categoryname) http://localhost:51888/forden/?categoryname=categoryname" >
but i want to display like:http://localhost:51888/forden/categoryname i want to hide the parameter in url, Is it possible .help me if any one knows.
The prefered way would be to use the IIS Url Rewrite module and then you can create rewrites in
web.config
. See examples at http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-moduleIf you can't install it, then you can also create rewrite rules in the file
/config/urlRewriting.config
in Umbraco. In your case the latter would be something like:You might need to experiment, but that's the basics.
While URL rewriting is a workable solution, I would recommend trying to use a content finder and URL provider first:
Basically, content finders allow you to use custom URL's to find your content. And URL providers ensure Umbraco is aware of what URL's you want to use for a given content node (e.g., when you type
Model.Content.Url
).The URL provider might not be as useful in your case if you have only one content node and multiple URL's (though I think it'd probably still work). The content finder would definitely be a good bet.
Well, umbracoalias is one of the option to go with and you can modify your url accordingly https://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracourlalias/
Manish
Thank you Manish, If u Don't mind can you explain clearly please , i can't get what u said.
Hi Dan,
I tried your Example but it display same thing in the Url like <http://localhost:51888/forden/?categoryname=categoryname" > is there any possibility go Get <http://localhost:51888/forden/categoryname" > like this
A URL rewrite means that you can enter the URL of http://localhost:51888/forden/categoryname but it will translate that to http://localhost:51888/forden/?categoryname=categoryname
So to use URL rewrites you need to generate the URL yourself in your links, and then the rewrite will do the job of passing on the query string. See docs at https://github.com/aspnetde/UrlRewritingNet/tree/master/docs
Raja
here are some url which can help you how to use this 1. http://stackoverflow.com/questions/25033540/how-to-change-url-names-in-umbraco 2. http://www.mayflymedia.co.uk/blog/umbraco/alternate-page-name-in-umbraco-using-umbracourlalias/
You can use in above manner
Manish
You may have to tinker with Dan's example rewrite rule before it will work for you. For example, I noticed he has a trailing slash, but your example URL does not have a trailing slash.
Also, Dan is using automatic capture groups (or whatever they are called). Note that you can also used named capture groups to be more explicit. Here is an example
UrlRewriting.config
file from one of my sites for your reference:There are a few rules in there you can use to serve as a reference. As an example, the first one ensures that when a user visits
~/en-us/some-page
, the server will interpret that URL as~/some-page?lang=en-us
. It will not do a redirect (i.e., the user will always see~/en-us/some-page
)... it's just that the server will see the modified URL.is working on a reply...