First we define which URLs we want to handle. In this case all URLs that end with page and then a number. We do that using Regex like this:
<match url="(.+)/page([0-9]+)$" />
We then tell IIS what we want to do with this request. In this case we rewrite (so we keep the url with e.x. "page4" in the URL. We then tell IIS how we want it to treat the URL. In this case we want it to treat it like its R1 (the first parentheses in the "<match url"-string). We then add the page-querystring-parameter with R2 (second parentheses in the "<match url"-string).
<action url="{R:1}?page={R:2}" type="Rewrite" />
This is a screenshot of a working sample in a normal .NET website (that's why i've added the ".aspx").
The plus sign tells the IIS that there should be 1 or more characters in the previous match - in your case that's the [_0-9a-z-]
You can test the changes on one of the many online tools for checking regex-expressions. I recommend https://regexr.com/ - It also has a cheatsheet that tells you what the different characters mean.
pagination friendly url
Hello
Trying to make a beautiful url in page navigation But not how it does not work
I have such a URL
I know I need to use
But I can't figure out how to do it.
Explanation:
First we define which URLs we want to handle. In this case all URLs that end with page and then a number. We do that using Regex like this:
We then tell IIS what we want to do with this request. In this case we rewrite (so we keep the url with e.x. "page4" in the URL. We then tell IIS how we want it to treat the URL. In this case we want it to treat it like its R1 (the first parentheses in the "<match url"-string). We then add the page-querystring-parameter with R2 (second parentheses in the "<match url"-string).
This is a screenshot of a working sample in a normal .NET website (that's why i've added the ".aspx").
Hope this helps :)
I get a 404 error I understand that this will work in non umbraco
This regex does not allow for traling slashes. Try: http://localhost50554/simvolika/page1
If you prefer a trailing slash you could try this regex instead:
Thank you so much, it works great.
Hello I'm trying to rewrite the redirect rule for url http://localhost:50554/tags/teg-1/page2/
But I get error 404 What am I doing wrong ?
Hey Lev
I think you're missing a "+" in your first group.
should be:
The plus sign tells the IIS that there should be 1 or more characters in the previous match - in your case that's the [_0-9a-z-]
You can test the changes on one of the many online tools for checking regex-expressions. I recommend https://regexr.com/ - It also has a cheatsheet that tells you what the different characters mean.
Unfortunately, he still gives out 404
Dennis, thank you for explaining how this works. Super helpful, I've never been able to make sense of these querystring rewrites until now.
it's not work (i am using umbraco13)
i fixed it by doing following steps
a class="dropdown-item" href="~/@(isEnglish?"":"ar/")Technologies/@item.Value">@item.Text in the url change id to be /
old version was
in the page that will dis[play the item to get slug
key will be the get document name ( consider that item.value is document name
is working on a reply...