Copied to clipboard

Flag this post as spam?

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


  • Joshua Sherer 10 posts 110 karma points
    Nov 12, 2015 @ 06:03
    Joshua Sherer
    0

    Regex to redirect if URL does not contain en|admin|umbraco

    Hi folks. I'm hoping for a little regex help here. Until the site will be adding more locales, I'd like to redirect requests the don't match ~/en or ~/admin or ~/|umbraco to the ~/en directory. The negative look-ahead approach isn't working for me. Perhaps my syntax is incorrect?

    I know that Regex fundamentally is a toolset to find matches (patterns) strings and not act upon grouped character mismatches, but I thought I'd just throw this out there and see if anyone has any "production-worthy" ideas.

    Any suggestions?

      <add name="foobar-redirect"
      virtualUrl= "~/(?!en|admin|umbraco).+/(.*)"
      rewriteUrlParameter="ExcludeFromClientQueryString"
      destinationUrl="~/en/$1"
      ignoreCase="true"
      redirect="Application"
      redirectMode="Temporary" />    
    
  • Per Olsson 47 posts 307 karma points
    Nov 12, 2015 @ 07:53
    Per Olsson
    1

    IIS (Internet Information Service) actually have a really good tool to test your URL-rewrites.

    Open IIS > Click on any "site" > URL Rewrite > And add a new Inbound rule.

    enter image description here

    If you can't find the URL Rewrite module make sure it's installed. https://www.iis.net/downloads/microsoft/url-rewrite

  • Mike Chambers 635 posts 1252 karma points c-trib
    Nov 12, 2015 @ 10:18
  • Joshua Sherer 10 posts 110 karma points
    Nov 12, 2015 @ 19:10
    Joshua Sherer
    0

    Thanks you guys! I rethought how to approach the issue and wrote a regex to solve my woes! I have to find how to manage my IIS from Visual Studio since that is how I'm managing my local Umbraco installation, and the Expresso app looks dope! Thanks again :-)

Please Sign in or register to post replies

Write your reply to:

Draft