Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David 28 posts 156 karma points
    Feb 28, 2017 @ 12:21
    David
    0

    URL Rewrite with URLRewriting.config

    Hello,

    I've got the following problem. I need to rewrite the URL for SEO. There are many news that I'Ve got. So I need a global rule.

    Current URL : /news/firstnews?page=2

    Needed URL : /news/firstnews/page/2

    Version: I am using Umbraco version 7.5.3

    What I tried: I've added the following snippet into the UrlRewriting.config

     <rewrites>
       <add name="NewsRule"
          virtualUrl="^~/news/(.*)/(.*)"
          destinationUrl="~/news.aspx?$1=$2"
          rewriteUrlParameter="ExcludeFromClientQueryString"
          ignoreCase="true" />  </rewrites>
    

    This doesnt work. Can anyone help me?

    Thank you in advance

    David

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Feb 28, 2017 @ 12:24
    Michaël Vanbrabandt
    0

    Hi David,

    a better way would be to use the Url Rewrite in IIS because this feature will be removed in the future of Umbraco.

    Why do you need to include the 'page' string in the destination url? Wouldn't it be more practical to use a url like /news/firstnews/2 ?

    /Michaël

  • David 28 posts 156 karma points
    Feb 28, 2017 @ 13:30
    David
    0

    Thank you for the fast answer.

    The Page string isnt needed in the destination url.

    So this solution "/news/firstnews/2" would be also ok.

    The problem is that umbraco says, that this page doesnt exist.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Feb 28, 2017 @ 14:02
    Michaël Vanbrabandt
    0

    Hi David,

    something is not clear to me. You are redirecting to the news.aspx?... page but shouldn't this be /news/firstnews?page=$1 and your virtualUrl /news/firstnews/(.*) ?

    /Michaël

  • David 28 posts 156 karma points
    Feb 28, 2017 @ 14:21
    David
    0

    Yes you are right Michaël. I was in hurry so my post was wrong. Sorry for that.

    I want to build a pager for my newslist. Like I want to show 5 news elements per page. And if I got 10 elements, there should be 2 pages.

     <add name="NewsRule"
          virtualUrl="^~/news/(.*)"
          destinationUrl="~/news?page=$1"
          rewriteUrlParameter="ExcludeFromClientQueryString"
          ignoreCase="true" />
    

    Thank you for your help

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Feb 28, 2017 @ 14:26
    Michaël Vanbrabandt
    0

    ok,

    now we are getting somewhere.

    Maybe this post will help you:

    https://our.umbraco.org/forum/developers/razor/41166-Razor-Paging-snippet

    /Michaël

  • pavel ringelhan 7 posts 78 karma points
    Jan 06, 2019 @ 14:30
    pavel ringelhan
    0

    Hi I have a similar problem. I'm trying to use iis url rewrite to overwrite the following address: ..../pobocky?filter=test on .../pobocky/test I have a rule set:

    <rewrite>
            <rules>
                <rule name="pobocky" stopProcessing="false">
                    <match url="^/pobocky/([_0-9a-z-]+)" negate="false" />
                    <action type="Rewrite" url="/pobocky?filter={R:1}" appendQueryString="true" logRewrittenUrl="true" />
                </rule>
            </rules>
    

    but I still get 404. What am I doing wrong Thanks

Please Sign in or register to post replies

Write your reply to:

Draft