如何解决此问题:规则集无法转换为等效的 IIS 格式,因为不支持控制流标志 (C、S、N)



我正在将网站从Linux服务器移动到Windows 2016,需要导入.htaccess重写规则。我在这些规则上收到上述错误:

# if this request is for "/" or has already been rewritten
RewriteCond $1 ^(index.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 .(css|js)$ [NC,OR]
# or if root images folder
RewriteCond %{REQUEST_URI} ^/images(.*) [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1,L]
RewriteCond $2 .(gif|jpg|png|jpeg)$ [NC]
RewriteRule (.+)/images/([^/]+) /images/$2 [S=1,L]
# else rewrite the request
RewriteRule . /index.php [QSA,L]

我对 Linux 的经验很少,希望有人可以帮助解决这个问题。

根据您的描述,我建议您尝试使用以下 url 重写规则:

<rewrite>
<rules>
<!--# then skip the rewrite to WP-->
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<!--# if this request is for "/" or has already been rewritten-->
<add input="{R:1}" pattern="^(index.php)?$" ignoreCase="false" />
<!--# or if request is for image, css, or js file-->
<add input="{R:1}" pattern=".(css|js)$" />
<!--# or if root images folder-->
<add input="{URL}" pattern="^/images(.*)" />
<!--# or if URL resolves to existing file-->
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
<!--# or if URL resolves to existing directory-->
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="(.+)/images/([^/]+)" ignoreCase="false" />
<conditions>
<add input="{R:2}" pattern=".(gif|jpg|png|jpeg)$" />
</conditions>
<action type="Rewrite" url="/images/{R:2}" />
</rule>
<!--# else rewrite the request-->
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>

相关内容

最新更新