Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JacDev's avatar

Solved: IIS 8, laravel (web.config)

Hello,

I am using IIS 8 to deploy my laravel now, but have a minor problem. Everything is installed and working, but only if I manually add /index.php behind the domain name. So www.domain.com gives me a 403 forbidden (access is denied), but www.domain.com/index.php gives me my (almost complete) working website.

The other minor thing is that my images are not working (unless I add /public in front of the url's). But I don't want the /public part in the URL (otherwise people might start investigating and trying other folders and things like that). (Also my css and everything automatically gets filled with /public what can be seen in the webpage source)

So is it possible to remove the /public path in IIS altogether? So both my /403 gets removed and I don't have to add /public to all my image paths without breaking the rest of the code?

My web.config is as follows:

<?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>
        <handlers accessPolicy="Read, Execute, Script">
        </handlers>
        <rewrite>
            <rules>
                <rule name="Imported Rule 3" 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="public/index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
0 likes
7 replies
taijuten's avatar
Level 10

the issue isn't with your web.config.

IIS has a url rewrite module which you can use to import the .htaccess. However, you need to change the location of your "site" to the /public folder. In IIS7 at least, you can go onto your site on IIS manager, and click "basic settings" at the top right.

Instead of your path being

c:/inetpub/wwwroot/sitename

It should be

c:/inetpub/wwwroot/sitename/public
4 likes
JacDev's avatar

Thanks! I changed the path via Advanced Settings. Moved the web.config to the public folder and removed the /public/ from web.config and it does!

Awesome, nice how something so simple could give me so much problems (and was so easily fixed). Thanks man!

japracool's avatar

I used your web.config above, move to public folder, and change the path via "basic settings". Now I get HTTP Error 500.19 - Internal Server Error. What to do?

manchote's avatar

I've the same problem that you, after check :

  • good extensions installed
  • good PHP version
  • I put url root IIS on public folder through Right clic on website you want install laravel on IIS interface and "Manage WebSite" > "Advanced Settings" and change the directory for public like root website

But i must do that to work fine :

=> Give the rights to write for 2 users : Users ou IIS_IUSRS for 3 directories :

  • /vendor
  • /storage
  • /bootstrat/cache

After that i can see the laravel page and i am happy :)

3 likes
manchote's avatar

@Jaytee mais ferme ta gueule (ca fait du bien) ! à quoi bon de créer un autre sujet quand on peut centraliser et compléter la réponse d'une question.

pedronicpa's avatar

Módulo IIS Web Core Notificación MapRequestHandler Controlador StaticFile Código de error 0x80070002 Dirección URL solicitada http: //localhost:80/livewire/update Ruta de acceso física C:\inetpub\wwwroot\livewire\update

me sale esto y no me deja ocupar livewire/update esque no estoy trabajando por puertonos sino por directorio virtual

Please or to participate in this conversation.