我写的很简单.htaccess并在Windows Azure网站上测试它,但是mod_rewrite在那里没有用 . 为什么?我如何重新配置Azure?
AddDefaultCharset utf-8上的RewriteEngine
RewriteCond%!-f RewriteCond%!-d
RewriteRule ^ test.html $ test.php?% [L]
Azure网站无法识别 .htaccess 文件 .
.htaccess
Azure网站在Microsoft IIS上运行 .
IIS有一个URL Rewrite模块,非常类似于Apache的mod_rewrite . 您可以通过在站点根文件夹中包含 web.config 文件来配置URL重写规则 .
web.config
按照Creating Rewrite Rules文章向下滚动到"View the rule in Config file"以了解它的外观 .
您定义的规则在 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>
1 回答
Azure网站无法识别
.htaccess
文件 .Azure网站在Microsoft IIS上运行 .
IIS有一个URL Rewrite模块,非常类似于Apache的mod_rewrite . 您可以通过在站点根文件夹中包含
web.config
文件来配置URL重写规则 .按照Creating Rewrite Rules文章向下滚动到"View the rule in Config file"以了解它的外观 .
您定义的规则在
web.config
中将如下所示(并且最有可能按预期工作):