Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How to customize the default URL pattern to user friendly url in Umbraco 7.
As the url is dependent on content item name, if I change the content name of the item and publish it the url is changing. I want to come up with a solution where I can set my own url pattern as Its available in ASP.NET MVC.
I tried it and its working fine :)
what if i have a url : www.mysite.com/news/2016/some-news
and rewrite that to: www.mysite.com/news/some-news
How would i achieve that, i tried to do the above but doesn't solve my problem i am going through, any tips would be appreciated ?
the property umbracoUrlName only changes the url for the node. With this you can't remove parent elements from the url.
For this you can use the url rewrite config file in umbraco. There you can write a new rule to remove the year from the news url.
Documentation about the url rewriting in .net can be found here
I tried the following rule from the example, but that doesn't seem to have any effects. Do you have any idea what I should try?
Many thanks for a quick reply much appreciated.
can you try the following rule:
You have switched both urls. The virtual url is the one you will use and is not known in the umbraco system. The destinationurl will be the url that replaces the virtual url.
I am getting following error when i try that.
The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'TestProject.Models.ErrorPageView'.
Can you show me the code of the view?
I tried that again and got following Url: /news/2016/2016
so yes, it is working in some way. but not what i want.
What url are you using that gives this result?
If you go to http://www.mysite.com/news/some-news then you should see the page of http://www.mysite.com/news/2016/some-news
Shouldn't i get redirected to " /news/" when i visit this page "/news/2016" ?
No because of the rule you created you will be redirected to ~/news/2016/2016/.
That is the problem when you want to create custom routes. You could create a new rule for this but then you have to do it for all the years that have to come; eg 2017 / 2018 / 2019, ...
I wanted to rewrite to hide the year from path by paths
"/news/2016" and "/news/2016/some-news".
so basically I am stuck? I don't mind writing the rules for years, I can live with that for now.
I ended up moving all child node to "News" node by manually updating umbracoNode table.
It just doesn't look nice with all the news articles and neither I'm sure of how it will perform loading all the news over time in a single node.
Maybe this one could come in handy if you need to just hide some url part? I created it some time ago to avoid having to specify weird rewritings and have some flexibility.
I finally got to implement your solution and its working good. :)
Now, here is my question, do you have a nuget package for this solution?
Not yet - but I'm going to make one soon, since other people have requested it too.
great - it's a problem when you have to deploy the solution to different environments.
It looks very handy, it gives better structure in umbraco and have simplified url up front.
Thanks a lot :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted