.htaccess - Azure 中的 Mod_rewrite

标签 .htaccess azure

我编写了简单的 .htaccess 并在 Windows Azure 网站上对其进行了测试,但 mod_rewrite 在那里不起作用。为什么?如何重新配置​​我的 Azure?

重写引擎开启 添加默认字符集utf-8

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

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

最佳答案

Azure 网站无法识别

.htaccess 文件。

Azure 网站在 Microsoft IIS 上运行。

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

关注Creating Rewrite Rules文章并向下滚动到“查看配置文件中的规则”以了解它的外观。

您定义的规则在 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>

关于.htaccess - Azure 中的 Mod_rewrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17832840/

相关文章:

apache - .htaccess中的条件SetEnv?

azure - Http触发器Azure函数随机返回404

azure - 访问 Azure 指标

azure - 我可以在 Windows Azure 中托管应用程序并将数据库存储在不同的服务器上吗

c# - Azure,存储共享访问签名 2.0 的访问被拒绝

php - 当端口始终为 80 时重定向 HTTP > HTTPS

php - 首先会发生什么? .htaccess 或 php 代码?

javascript - 将文件夹中的所有文件重定向到另一个页面,但仍允许访问 html 文件

php - htaccess 中的 SetEnvIf Referer

c# - 如何发送延续 token 来查询azure时间序列见解?