0

我與您聯繫,因爲我在將Apache + PHP應用程序遷移到Azure時遇到問題。在Azure Web App中重寫策略

我使用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&amp;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&amp;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&amp;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&amp;abm_accion=m&amp;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? 謝謝

回答

0

根據您的描述和錯誤消息,我想你的翻譯結果可能有一些錯誤。

據我所知,IIS有一個url rewrite module,它可以轉換重寫角色。

我tranlate如下(而不是和你的一樣)重寫角色,我建議你可以使用下面的代碼,然後再試一次:

<rewrite> 
    <rules> 
    <rule name="Imported Rule 1" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)\.json$" ignoreCase="false" /> 
     <action type="Rewrite" url="{R:1}.json.php" appendQueryString="true" /> 
    </rule> 
    <rule name="Imported Rule 2" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)\-process\-add$" ignoreCase="false" /> 
     <action type="Rewrite" url="{R:1}_procesar.php?abm_accion=a" appendQueryString="true" /> 
    </rule> 
    <rule name="Imported Rule 3" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)\-process\-edit\-(.*)$" ignoreCase="false" /> 
     <action type="Rewrite" url="{R:1}_procesar.php?abm_accion=m&amp;id={R:2}" appendQueryString="true" /> 
    </rule> 
    <rule name="Imported Rule 4" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)\-process\-delete\-(.*)$" ignoreCase="false" /> 
     <action type="Rewrite" url="{R:1}_procesar.php?abm_accion=d&amp;id={R:2}" appendQueryString="true" /> 
    </rule> 
    <rule name="Imported Rule 5" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)\-add$" ignoreCase="false" /> 
     <action type="Rewrite" url="index.php?put={R:1}_am&amp;abm_accion=a" appendQueryString="true" /> 
    </rule> 
    <rule name="Imported Rule 6" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)\-edit\-(.*)$" ignoreCase="false" /> 
     <action type="Rewrite" url="index.php?put={R:1}_am&amp;abm_accion=m&amp;id={R:2}" appendQueryString="true" /> 
    </rule> 
    <rule name="Imported Rule 7" stopProcessing="true"> 
     <match url="^(zpanel\/)(.*)$" ignoreCase="false" /> 
     <conditions> 
     <add input="{URL}" pattern="(css|js|favicon|img|php|json|icon|process|report|fonts|ckeditor)" ignoreCase="false" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="index.php?put={R:1}" appendQueryString="true" /> 
    </rule> 
    </rules> 
</rewrite> 

您可以點擊URL重寫模塊中的IIS探險家首先。

然後你可以在右側找到導入規則。點擊按鈕,你會發現翻譯窗口。

enter image description here