2

I have created a PHP website on azure using app services. I use continuous deployment through bitbucket. I need to point the website to public folder in my code to run the app as it is built with zend framework.

After some search, was not able to find how to change the folder where the server points for default directory.

Ruchit Rami
  • 2,265
  • 4
  • 26
  • 53

3 Answers3

5

Go to Azure Web apps settings -> Application Settings -> Virtual Applications and directories and setup the physical path of the new folder. Also check the Application checkbox.

Restart the web app once.

Gandhali Samant
  • 869
  • 4
  • 10
1

There are a few scenarios possible:

  1. You run a Windows App Service
  2. You run a Linux App Service with PHP 7.4 or less
  3. You run a Linux App Service with PHP 8

In the first scenario (Windows App Service) you can go to the App Service > Settings > Configuration blade you need to select the tab "Path Mappings" where you can set the Virtual Applications paths as follows: "/" maps to "site\wwwroot\public".

Mapping of virtual maps

In the second scenario you can use the .htaccess solution described by @Ed Greenberg, even though for Zend Framework I suggest to use the following settings:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

For the third scenario you have a bit more of a challenge since Apache was replaced by Nginx and the rewrite rules no longer apply. Please see my detailed blog article "PHP 8 on Azure App Service" on how to solve this and other challenges with the new Azure App Service for PHP 8.

Good luck and let me know if it solved your problem.

DragonBe
  • 361
  • 1
  • 6
0

The correct answer in 2021 (for Laravel, and probably other frameworks with a /public directory) is to put an extra .htaccess in the webroot directory.

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Credit to Azure Web App - Linux/Laravel : Point domain to folder

Ed Greenberg
  • 91
  • 10