我正在尝试将 apache 上的网站移至 iis 8.5
一切正常,但有一条规则导致我的网站无法正常运行
RewriteCond %{REQUEST_URI} !\.(js|css|jpg|jpeg|gif|png)$ [or]
RewriteCond %{REQUEST_URI} apple-touch-icon\.png$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
有人可以将其翻译成 IIS 重写吗?
我找到了一些例子来做到这一点
<rule name="Webasyst Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="!\.(eot|ttf|woff|js|css|jpg|jpeg|gif|png)$" negate="true" />
<add input="{URL}" pattern="apple-touch-icon\.png$" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
和
<rule name="Webasyst Controller" stopProcessing="true">
<match url="[^eot|ttf|woff|js|css|jpg|jpeg|gif|png]$|apple\-touch\-icon\.png$" ignoreCase="false" />
<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" appendQueryString="true" />
</rule>
两者都不起作用
有人可以帮忙吗?
答案1
根据您问题中的第二个例子:
<rule name="Webasyst Controller" stopProcessing="true">
<match url="(\.(?!eot|ttf|woff|js|css|jpe?g|gif|png)|apple\-touch\-icon\.png)$" ignoreCase="false" />
<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" appendQueryString="true" />
</rule>