Laravel 4.1 in Windows Server IIS

Submitted by cyberid41 - 3 years ago

This is a simple trick that laravel run on IIS Server, this configuration will delete the public folder from the URL, but does not delete the public folder in the application. I was inspired by a trick-owned https://gist.github.com/leabdalla/6135627, but it can not load css, js, routing and other files. And I have experimented that overall laravel can run normally. this is my simple code, I put web.config in the root folder, and I did not change any of the main application, especially in public folders.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1">
                    <match url="^(.*)$" ignoreCase="false" />
                    <action type="Rewrite" url="/public/{R:1}" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^(.*)$" />
                    <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="public/index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Ads cover the costs of maintaining Laravel-tricks

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks