【发布时间】:2017-04-26 14:17:34
【问题描述】:
我正在与您联系,因为我在将 Apache + PHP 应用程序迁移到 Azure 时遇到问题。
我使用 Apache 重写模块来读取请求 URI 并将它们转换为正确的 URL。我已将这些指令翻译成 IIS 重写规则,但我无法让它们在 Azure 中工作。
规则是:
RewriteEngine on
RewriteRule ^(zpanel\/)(.*)\.json$ $1.json.php [QSA,L]
RewriteRule ^(zpanel\/)(.*)\-process\-add$ $1_procesar.php?abm_accion=a [QSA,L]
RewriteRule ^(zpanel\/)(.*)\-process\-edit\-(.*)$ $1_procesar.php?abm_accion=m&id=$2 [QSA,L]
RewriteRule ^(zpanel\/)(.*)\-process\-delete\-(.*)$ $1_procesar.php?abm_accion=d&id=$2 [QSA,L]
RewriteRule ^(zpanel\/)(.*)\-add$ index.php?put=$1_am&abm_accion=a [QSA,L]
RewriteRule ^(zpanel\/)(.*)\-edit\-(.*)$ index.php?put=$1_am&abm_accion=m&id=$2 [QSA,L]
RewriteCond %{REQUEST_URI} !(css|js|favicon|img|php|json|icon|process|report|fonts|ckeditor)
RewriteRule ^(zpanel\/)(.*)$ index.php?put=$1 [QSA,L]
所以我把它们翻译成:
<rewrite xdt:Transform="InsertIfMissing">
<rules xdt:Transform="InsertIfMissing">
<clear/>
<rule name="rule 1d" stopProcessing="true">
<match url="^(zpanel\/)(.*)\.json$" />
<action type="Rewrite" url="/{R:1}{R:2}.json.php" appendQueryString="true" />
</rule>
<rule name="rule 1l" stopProcessing="true">
<match url="^(zpanel\/)(.*)\-process\-add$" />
<action type="Rewrite" url="/{R:1}{R:2}_procesar.php?abm_accion=a" appendQueryString="true" />
</rule>
<rule name="rule 1x" stopProcessing="true">
<match url="^(zpanel\/)(.*)\-process\-edit\-(.*)$" />
<action type="Rewrite" url="/{R:1}{R:2}_procesar.php?abm_accion=m&id={R:3}" appendQueryString="true" />
</rule>
<rule name="rule 1U" stopProcessing="true">
<match url="^(zpanel\/)(.*)\-process\-delete\-(.*)$" />
<action type="Rewrite" url="/{R:1}{R:2}_procesar.php?abm_accion=d&id={R:3}" appendQueryString="true" />
</rule>
<rule name="rule 1S" stopProcessing="true">
<match url="^(zpanel\/)(.*)\-add$" />
<action type="Rewrite" url="/{R:1}index.php?put={R:2}_am&abm_accion=a" appendQueryString="true" />
</rule>
<rule name="rule 1V" stopProcessing="true">
<match url="^(zpanel\/)(.*)\-edit\-(.*)$" />
<action type="Rewrite" url="/{R:1}index.php?put={R:2}_am&abm_accion=m&id={R:3}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^(zpanel\/)(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/css|js|favicon|img|php|json|icon|process|report|fonts|ckeditor$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}index.php?q={R:2}" appendQueryString="true" />
</rule>
</rules>
但在此之后,我在 Azure 中不断收到相同的错误消息。 “找不到资源”。
翻译正常吗?我是否需要更改其他内容才能使其在 Azure 版本的 IIS 上运行? 谢谢
【问题讨论】:
标签: azure iis url-rewriting azure-web-app-service