Azure上的Yii2 Webapp无法正常工作 [英] Yii2 webapp on Azure not working

查看:51
本文介绍了Azure上的Yii2 Webapp无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分别基于Yii + Yii2框架构建的网站+服务应用程序.我尝试将其托管在Azure http://xxxxxx.azurewebsites.net/上.建立在Yii1上的网站运行正常.在Yii2端点上建立的服务返回404.这些服务在本地工作.

I am having a website + services app built on Yii + Yii2 framework respectively. I tried hosting it on Azure http://xxxxxx.azurewebsites.net/ . website which was built on Yii1 was working fine. Services built on Yii2 endpoint returning 404. the services are working in local.

以下是详细信息:

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工作正常.

Now when I try locally with url: http://localhost/myapp/v1/srvc/srvdetails is working fine.

当我尝试Azure URL时,即 http://xxxxxx.azurewebsites.net/v1/srvc/srvdetails 不起作用.

When I try Azure URL i.e. http://xxxxxx.azurewebsites.net/v1/srvc/srvdetails not working.

有人可以帮助我吗?

推荐答案

根据您的描述,似乎您的应用程序中有一个 .htaccess 文件隐藏了 index.php 模式.由于PHP脚本由Azure Web Apps上的IIS处理,因此您可以尝试生成具有以下内容的 web.config 文件,而不是您的 .htaccess :

According your description, it seems that you have a .htaccess file in your application to hidden index.php pattern in URL. As the PHP scripts are handled by IIS on Azure Web Apps, so you can try to generate a web.config file with following content to instead your .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>

否则,您可以为我们提供完整的应用程序结构,以进行进一步的诊断.如有任何其他疑问,请随时告诉我.

Otherwise, you can provide your complete application structure for us for further diagnosis. Any further concern, please feel free to let me know.

这篇关于Azure上的Yii2 Webapp无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆