我正在将使用APIGILITY
开发的API部署到IIS。由于IIS不支持.htaccess,我试图从.htaccess文件的内容创建web.config文件。我使用IISv7.5并尝试安装URL重写器来转换规则。但是我转换时出错了。请在下面找到.htaccess文件以及我从urlRewriter获得的相应转换。
.htaccess文件
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]
我转换的规则和错误。
<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>
我可以得到一些帮助吗?
答案 0 :(得分:1)
我找到了解决方案here
基本上,安装IIS URL Rewrite extension,然后使用此内容在apigility的root上创建一个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>