mod_rewrite的在Azure中 [英] Mod_rewrite in Azure
问题描述
我是在Windows Azure网站编写简单的.htaccess和测试,但mod_rewrite的没有在那里工作。为什么?我怎样才能reconfigurate我的Azure?
I was write simple .htaccess and test it on Windows Azure Web Sites, but mod_rewrite didn't work there. Why? How I can reconfigurate my Azure?
RewriteEngine叙述上 AddDefaultCharset UTF-8
RewriteEngine on AddDefaultCharset utf-8
的RewriteCond%{} REQUEST_FILENAME!-f 的RewriteCond%{} REQUEST_FILENAME!-d
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
重写规则^ test.html的$ test.php的?%{QUERY_STRING} [L]
RewriteRule ^test.html$ test.php?%{QUERY_STRING} [L]
推荐答案
的.htaccess
文件不是recognizible通过Azure网站。
.htaccess
file is not recognizible by Azure Web Sites.
Azure网站。
IIS有一个URL重写模块,mod_rewrite的Apache的非常相似。你可以通过在你的站点根目录文件夹中的的web.config
文件配置URL重写规则。
IIS has a URL Rewrite module, very similar to mod_rewrite for Apache. You can configure URL Rewrite rules by having a web.config
file in your site root folder.
按照<一href="http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module">Creating重写规则文章和向下滚动到查看配置文件中的规定,以得到一个想法是什么样子。
Follow the Creating Rewrite Rules article and scroll down to the "View the rule in Config file" to get an idea what it looks like.
您定义的规则,看起来像这样的的web.config
(将最有可能按预期):
Your rules defined, will look like this in web.config
(and will most probably work as expected):
<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>
这篇关于mod_rewrite的在Azure中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!