0

I am new to IIS and trying to translate into it the following Apache rule:

# prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.) 
# - except let's encrypt challenge
RedirectMatch 403 ^/?\.(?!/well-known/acme-challenge/[\w-]{43}$)

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]

The idea of the rule is prevent IIS from serving:

  • Any file than starts with “.”, or

  • Any folder that starts with “.” but the folder “./well-known/acme-challenge”

Thanks in advance ;)

VPDD
  • 131
  • 4
  • 7

1 Answers1

0

It seems [E=BASE:%1] cannot be translated to IIS

the 1st part

# prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.) 
# - except let's encrypt challenge
RedirectMatch 403 ^/?\.(?!/well-known/acme-challenge/[\w-]{43}$)

this will translated onto web.config as

<rule name="Deny files and folderd starting with . but allow folder .well-known" patternSyntax="ECMAScript" stopProcessing="true">
   <match url="(^\.|\/\.(?!well-known))" ignoreCase="true" negate="false" />
   <conditions logicalGrouping="MatchAll">
   </conditions>
   <action type="AbortRequest" />
</rule>

Hope it helps others ^^

VPDD
  • 131
  • 4
  • 7