简体   繁体   中英

Execute Php on web root of Azure Web App

I'm trying out Azure Web apps but I've developing websites and other web apps on "normal" servers that run Linux (OK whatever hosting you get when you buy a domain) What happens is if there is an index.php in the root folder it gets executed without the need for adding the name of the php file in the url, basically www.example.com will be the same* as www.example.com/index.php. I want that in azure websites, currently I have to keep adding the php file name in the url to get anywhere which is not feasible for all scenarios, if I don't I get "You do not have permission to view this directory or page." I've run out of ideas to make that possible, some help would be nice...

In web.config define index.php as the first file to be processed by the server

    <configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Kanboard-nice-urls" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Or simply open your Web App -> Application Settings blade and add index.php at the top of Default documents :

默认文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM