2013-07-24 35 views
8

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

RewriteEngine叙述上 AddDefaultCharset UTF-8

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

重写规则^ $的test.html test.php的?%{QUERY_STRING} [L]

+1

我找到了解决方案,我用的Web.config – user1958350

回答

15

.htaccess文件不被Azure网站认可。

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> 
+0

我相信你可以安装一个扩展,这将使htaccess文件被读取。 http://www.helicontech.com/isapi_rewrite/但不是免费的 – Miguel