Copied to clipboard

Flag this post as spam?

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


  • Peter Cort Larsen 421 posts 1038 karma points
    Jun 30, 2014 @ 10:12
    Peter Cort Larsen
    0

    UrlRewriting rule, ?p=123 to folder like struture

    Hi,

    I am struggling with a URLrewrite and cant seem to get into work.

    I have this type of url:

    /order/choose-tyres?plate=UU25716

    The 'choose-tyres' can vary.

    I am trying to get this result:
    /choose-tyres/UU25716

    My latest attempt. Can anyone help?

     

    virtualUrl="^~/order/(.*)?plate=(.*)" 
    rewriteUrlParameter="ExcludeFromClientQueryString"
    destinationUrl="~/$1/$2"
    ignoreCase="true" />
  • Bilal Isa 60 posts 76 karma points
    Jun 30, 2014 @ 11:37
    Bilal Isa
    0

    Do you want to put your rule in umbracoSettings.config?

    Have you considered the IIS rewrite module? I find it personally easier to work with and performs better. I can probably provide some examples of the latter and a rewrite rule for the above mentioned redirect rule if you want to go with the IIS rewrite module which probably requires at least IIS 7.

    Kind regards,

    Bilal

  • Peter Cort Larsen 421 posts 1038 karma points
    Jul 01, 2014 @ 13:12
    Peter Cort Larsen
    0

    Hi,

     

    in umbracoSettings.config: Is that an option?

    Dont really care where the rule is, as longs as it works.

     

    IIS rewrite module
    Might be difficult on shared hosting, or? 

  • Peter Cort Larsen 421 posts 1038 karma points
    Jul 01, 2014 @ 13:14
    Peter Cort Larsen
    0

    Actually i can acces my site thru IIS, even on shared hosting.

    Did you have some examples?

     

  • Bilal Isa 60 posts 76 karma points
    Jul 01, 2014 @ 13:48
    Bilal Isa
    0

    Sorry, I meant UrlRewriting.config in the config folder in the root site, not umbracoSettings.config.

    I don't think it will be a problem on a shared hosting environment because the rewrite rules will be relative to your IIS site. I can do a POC on that if you like. I've only tried on a dedicated server and I went with that solution because I read somewhere that the URL rewriting engine in umbraco does not perform so good.

    However the IIS rewrite module extension has to be installed in order for it to work. You can either write the rules directly in your web.config or in the IIS interface. The request is handled directly by the IIS.

    Here are some real life examples from a specific client

    </httpProtocol>

    <rewrite>

          <rules>

            <clear />

            <rule name="Static Redirect 35" stopProcessing="true">

              <match url="dk/showpage\.aspx$" />

              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

                <add input="{QUERY_STRING}" pattern="pageid=785" />

                <add input="{QUERY_STRING}" pattern="m901ID=1013" />

              </conditions>

              <action type="Redirect" url="afdelinger/emerging-markets-aktier" appendQueryString="false" redirectType="Permanent" />

            </rule>

            <rule name="Static Redirect 2" stopProcessing="true">

              <match url="dk/showpage\.aspx$" />

              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

                <add input="{QUERY_STRING}" pattern="pageid=374" />

              </conditions>

              <action type="Redirect" url="afdelinger/afdelingsoversigt" appendQueryString="false" redirectType="Permanent" />

            </rule>

            <rule name="Static Redirect 5" stopProcessing="true">

              <match url="dk/showpage\.aspx$" />

              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

                <add input="{QUERY_STRING}" pattern="pageid=1905" />

              </conditions>

              <action type="Redirect" url="/" appendQueryString="false" redirectType="Permanent" />

            </rule>

            <rule name="Rewrite Rule">

              <match url=".*" />

              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

                <add input="{Static Redirects:{REQUEST_URI}}" pattern="(.+)" />

              </conditions>

              <action type="Rewrite" url="{C:1}" />

            </rule>

          </rules>

          <rewriteMaps>

            <rewriteMap name="Static Redirects">

              <add key="/dk/afdelinger" value="/afdelinger/afdelingsoversigt" />

            </rewriteMap>

          </rewriteMaps>

        </rewrite>

      </system.webServer>

  • Bilal Isa 60 posts 76 karma points
    Jul 01, 2014 @ 13:51
    Bilal Isa
    0

    The idea is to place the specific rules at the top so they get hit first so the order of the redirects matters.

Please Sign in or register to post replies

Write your reply to:

Draft