Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

php - Yii2 webapp on Azure not working

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.

Here are the details:

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

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

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

Can someone help me?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...