Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Mar 20, 2015 @ 11:00
    Ismail Mayat
    0

    Restrict access to /Umbraco

    Guys,

    I am trying prevent access to /Umbraco using IIS rewrite, so for Umbraco directory I have the following web.config

    <configuration>
      <system.webServer>
        <rewrite>
          <rewriteMaps>
            <rewriteMap name="Allowed Urls">
              <add key="/umbraco/webservices/cacheRefresher.asmx" value="1" />
              <add key="/umbraco/Surface/CommentSurface/AddLike/" value="1" />
              <add key="/umbraco/Surface/ReviewSurface/AddLike/" value="1" />
              <add key="/umbraco/Surface/CommentSurface/ReportComment/" value="1" />
              <add key="/umbraco/Surface/CommentSurface/GetComments/" value="1" />
              <add key="/umbraco/Surface/ReviewSurface/GetProductReviews/" value="1" />          
            </rewriteMap>
          </rewriteMaps>
          <rules>
            <rule name="Disable Umbraco access" enabled="true" stopProcessing="true">
              <conditions>
                <add input="{Allowed Urls:{HTTP_URL}}" pattern="1" negate="true" />
              </conditions>
              <match url="(.*)" />
              <action type="Redirect" url="http://{HTTP_HOST}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>

    So when i try to do /umbraco i get redirected to the home page. I am trying to create an ignore list of urls, so the urls in rewritemap i want those to be ignored.  The first url works fine so if i hit

    /umbraco/webservices/cacheRefresher.asmx

    I can get to it.  The other urls do not work they redirect to home page.  I want those to resolve as they are called on certain pages using ajax.  Can anyone see where I am going wrong?

    Cheers

    Ismail

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    Mar 20, 2015 @ 11:06
    Dave Woestenborghs
    1

    Hi Ismail,

    Maybe this article can help you out ?

    http://tcmorris.net/blog/custom-domain-for-umbraco/

    Dave

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Mar 20, 2015 @ 15:03
    Ismail Mayat
    0

    Dave,

    I can get that to work if i put the re writes in root directory, however I cannot get it to work with my other url cacheRefresher.  

    In theory the original config i posted should work, in the list urls i just tried one of the surface controller ones only still no joy,  either it does not like extentionless url or the non working urls have querystrings and that is causing issue? So near yet to so far GRRRRR.

    Regards

    Ismail

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Mar 20, 2015 @ 15:29
    Chriztian Steinmeier
    0

    Hi Ismail,

    I'm not familiar with rewrites in web.config, but when doing rewrites in the UrlRewriting.config file, there's a couple of additional attributes that decide on what to do with the QueryString - maybe you need to check if something like that's available when doing it in web.config as well?

    Or maybe you just need to add (.*) to the other URLs to make sure any "extras" are accounted for?

    /Chriztian

  • Dan Lister 416 posts 1974 karma points c-trib
    Mar 20, 2015 @ 16:50
    Dan Lister
    101

    Hey Ismail,

    I think rewrite maps do not allow for regular expressions. You could try the following instead:

    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <rule name="Disable Umbraco access" enabled="true" stopProcessing="true">
              <match url="(.*)" ignoreCase="false" />
                <conditions>
                  <add input="{PATH_INFO}" pattern="/umbraco/webservices/(.*)" negate="true" />
                  <add input="{PATH_INFO}" pattern="/umbraco/Surface/ReviewSurface/(.*)" negate="true" />
                  <add input="{PATH_INFO}" pattern="/umbraco/Surface/CommentSurface/(.*)" negate="true" />
                </conditions>
              <action type="Redirect" url="http://{HTTP_HOST}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    

    Hope that helps.

    Thanks, Dan.

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Mar 20, 2015 @ 16:58
    Ismail Mayat
    0

    Dan,

    Bingo, many many thanks for this.

    Regards

     

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft