【发布时间】:2020-11-07 10:54:07
【问题描述】:
我在使用可以在各种语言中看到的目录/变量规则时遇到问题。 例如:
应该读作 example.com,其中 foo 和 bar 作为变量。
但是在 IIS 中,无论我进行多少重写,它似乎都无法识别这一点。这是有效的 apache .htaccess 文件:
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine Options
RewriteBase /richie/public
RewriteCond %{REQUEST_FILENAME} "-d
RewriteCond %{REQUEST_FILENAME} "-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
public文件夹中转换/对应的IIS web.config文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule1" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
但是 IIS 似乎忽略了它......我只是得到 404,因为目录不存在(它不存在,因此重写)。
有什么想法吗?
【问题讨论】: