praveen seela praveen seela - 23 days ago 6
PHP Question

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?

Answer

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.