Htaccess rules (mod_rewrite) translation into web.config rules

I am deploying an API that I developed using APIGILITYfor IIS. Since IIS does not support .htaccess, I am trying to create a web.config file from the contents of a .htaccess file. I used IISv7.5 and tried to install a URL converter to translate the rules. But I get an error message while converting. Below is the .htaccess file and the corresponding conversion that I get from urlRewriter.

.htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

the converted rules and the errors that I get.

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^.*$" />
      <conditions logicalGrouping="MatchAny">
        <!--The condition pattern is not supported: -s.-->
        <!--The condition pattern is not supported: -l.-->
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
      </conditions>
      <action type="None" />
    </rule>
    <!--The rule cannot be converted into an equivalent IIS format because of unsupported flags: E-->
    <!--This rule was not converted because it contains references that are not supported: 'ENV::BASE'-->
  </rules>
</rewrite>

Can anyone help me?

+4
source share
1 answer

I found a solution here

, URL- URL- IIS, web.config :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <httpErrors existingResponse="PassThrough" />
        <rewrite>
          <rules>
            <clear />
            <!-- Rewrite rules to /public by @maartenballiauw *tnx* -->
            <rule name="TransferToPublic-StaticContent" patternSyntax="Wildcard" stopProcessing="true">
              <match url="*" />
              <conditions logicalGrouping="MatchAny">
                <add input="{REQUEST_URI}" pattern="*assets*" />
                <add input="{REQUEST_URI}" pattern="robots.txt" />
              </conditions>
              <action type="Rewrite" url="public/{R:0}" />
            </rule>
            <rule name="TransferToPublic" patternSyntax="Wildcard">
              <match url="*" />
              <action type="Rewrite" url="public/index.php" />
            </rule>
          </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="index.html" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>
+1

All Articles