Azure上的Yii2 web应用程序无法工作


Yii2 webapp on Azure not working

我有一个网站+服务应用程序分别建立在Yii + Yii2框架。我试着把它托管在Azure http://xxxxxx.azurewebsites.net/上。在yi11上建立的网站运行良好。基于Yii2端点构建的服务返回404。服务在本地工作。

详情如下:

Local: Xampp server
htdocs/
       myapp/
             dashboard/            ---> this the website folder (Yii)
             modules/
                     v1/           -----> here are my yii2 services and controllers.

现在,当我尝试本地url: http://localhost/myapp/v1/srvc/srvdetails

当我尝试Azure URL即http://xxxxxx.azurewebsites.net/v1/srvc/srvdetails不工作。

有人能帮帮我吗?

根据您的描述,您的应用程序中似乎有一个.htaccess文件来隐藏URL中的index.php模式。由于PHP脚本是由Azure Web应用程序上的IIS处理的,所以你可以尝试生成一个web.config文件,其中包含以下内容来代替你的.htaccess:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
  <rewrite>
    <rules>
      <rule name="Hide Yii Index" stopProcessing="true">
        <match url="." ignoreCase="false" />
        <conditions>
        <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="index.php" appendQueryString="true" />
      </rule> 
    </rules>
  </rewrite>
</system.webServer>
</configuration>

否则,您可以提供完整的应用程序结构供我们进一步诊断。如有任何问题,请随时与我联系。

相关文章: