Azure中的Mod_rewrite

use*_*350 9 .htaccess azure

我写的很简单.htaccess并在Windows Azure网站上测试它,但是mod_rewrite在那里没有用.为什么?我如何重新配置​​Azure?

AddDefaultCharset utf-8上的RewriteEngine

RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d

RewriteRule ^ test.html $ test.php?%{QUERY_STRING} [L]

ast*_*kov 16

.htaccess Azure网站无法识别文件.

Azure网站在Microsoft IIS上运行.

IIS有一个URL Rewrite模块,非常类似于Apache的mod_rewrite.您可以通过web.config在站点根文件夹中包含文件来配置URL重写规则.

按照创建重写规则一文并向下滚动到"在配置文件中查看规则"以了解它的外观.

您定义的规则将如下所示web.config(并且最有可能按预期工作):

<rewrite>
    <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
            <match url="^test.html$" ignoreCase="false" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            </conditions>
            <action type="Rewrite" url="test.php?{QUERY_STRING}" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)