Copied to clipboard

Flag this post as spam?

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


  • Son Pham 31 posts 72 karma points
    Aug 25, 2018 @ 17:29
    Son Pham
    0

    IIS Rewrite in Umbraco 7.12.1

    Hi,

    I have just installed Umbraco 7.12.1 from scratch. I can see the old way with URLRewriting.config file has been deprecated. I have tried with IIS rewrite instead but not succeeded.

    Example I have a URL https://mysite.com/contact I would like when user types that URL. It will become https://mysite.com/contact.html

    I have tried this

    <rewrite>
           <rules>         
             <rule name="Rewrite rule1 for RewriteHtml">
               <match url=".*" />
               <conditions>
                 <add input="{RewriteHtml:{REQUEST_URI}}" pattern="(.+)" />
               </conditions>
               <action type="Rewrite" url="{C:1}" appendQueryString="false" />
             </rule>
           </rules>
           <rewriteMaps>
             <rewriteMap name="RewriteHtml">
               <add key="/contact.html" value="/contact" />
             </rewriteMap>
           </rewriteMaps> 
    </rewrite>
    

    How can I achieve this in new Umbraco? Thanks very much

  • Ben Palmer 176 posts 842 karma points c-trib
    Aug 26, 2018 @ 11:30
    Ben Palmer
    0

    Hi,

    I think you may have your key and value the wrong way around:

    <add key="/contact.html" value="/contact" />
    

    Should be:

    <add key="/contact" value="/contact.html" />
    

    Hope that works for you!

    Ben

  • Son Pham 31 posts 72 karma points
    Sep 03, 2018 @ 15:14
    Son Pham
    0

    Hi Ben,

    That worked fine but both links can be accessible as well. How can we avoid this? So if user access to "/contact" then they should get a 404.

  • Ben Palmer 176 posts 842 karma points c-trib
    Sep 03, 2018 @ 16:16
    Ben Palmer
    0

    Hi,

    When you say it's working, what's happening?

    With the above rule /contact should take you to /contact.html every time. Unless you mean /contact/ (notice the trailing slash)?

    Thanks,

    Ben

  • Son Pham 31 posts 72 karma points
    Sep 03, 2018 @ 16:27
    Son Pham
    0

    Thanks for you reply Ben

    it is working with these url: .../contact .../contact.html .../contact/ (no matter this works or not)

    I would like ONLY ".../contact.html" work. the rest should return 404.

    Can we do this in Umbraco? Thanks

Please Sign in or register to post replies

Write your reply to:

Draft