Deploying Grav CMS to Azure Deploying Grav CMS to Azure azure azure

Deploying Grav CMS to Azure


As PHP applications running on Azure are hosted on IIS, so your issue occurs due to you haven't configured the URL rewrite mode in IIS.

Try to create a file named web.config in the root directory of your application, with the following content:

<?xml version="1.0" encoding="UTF-8"?><configuration>    <system.webServer>        <defaultDocument>            <files>                <remove value="index.php" />                <add value="index.php" />            </files>        </defaultDocument>        <rewrite>            <rules>                <rule name="request_filename" stopProcessing="true">                    <match url="." ignoreCase="false" />                    <conditions logicalGrouping="MatchAll">                        <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" />                </rule>                <rule name="user_accounts" stopProcessing="true">                    <match url="^user/accounts/(.*)$" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="user_config" stopProcessing="true">                    <match url="^user/config/(.*)$" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="user_error_redirect" stopProcessing="true">                    <match url="^user/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="cache" stopProcessing="true">                    <match url="^cache/(.*)" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="bin" stopProcessing="true">                    <match url="^bin/(.*)$" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="backup" stopProcessing="true">                    <match url="^backup/(.*)" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="system" stopProcessing="true">                    <match url="^system/(.*)\.(txt|md|html|yaml|php|twig|sh|bat)$" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>                <rule name="vendor" stopProcessing="true">                    <match url="^vendor/(.*)\.(txt|md|html|yaml|php|twig|sh|bat)$" ignoreCase="false" />                    <action type="Redirect" url="error" redirectType="Permanent" />                </rule>            </rules>        </rewrite>    </system.webServer>    <system.web>        <httpRuntime requestPathInvalidCharacters="<,>,*,%,&,\,?" />    </system.web></configuration>

And then deploy it with your application to Azure. Also, you can find this config file in the webserver-configs folder in your grav application. Or you can refer to https://github.com/Vivalldi/grav/blob/develop/webserver-configs/web.config at github.

Any further concern, please feel free to let me know.


As of March 2018, I found I also needed to install the composer extension in order to get the website to load properly.

See https://docs.microsoft.com/en-gb/azure/app-service/web-sites-php-configure#how-to-enable-composer-automation-in-azure for details.

Without doing this I would see a blank page when trying to load the site.