gpt4 book ai didi

apache - htaccess 规则 (mod_rewrite) 转换为 web.config 规则

转载 作者:行者123 更新时间:2023-12-04 15:00:27 31 4
gpt4 key购买 nike

我正在部署我使用 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>

我能得到一些帮助吗?

最佳答案

我找到了解决方案 here

基本上,安装 IIS URL Rewrite extension ,然后创建一个 web.config使用以下内容在 apigility 的根目录上创建文件:

<?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>

关于apache - htaccess 规则 (mod_rewrite) 转换为 web.config 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30263188/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com