A client has a server with Windows Server 2008 installed, running IIS 7.5 and ISAPI 3 (TASK hosting).
I needed to put a Laravel project running his server, and the problem was the rewrite needed for the framework. How I would do the htaccess from Laravel work on IIS?
Before continuing the explanation, read the conceptual part I did over IIS on this post:
The configuration I did on web.config is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<?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"> <add name="PHP-FastCGI" path="*.php" verb="GET,HEAD,POST,PUT,DELETE" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.4\php-cgi.exe" resourceType="Either" requireAccess="Script" /> </handlers> <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> <httpRedirect enabled="false" destination="" exactDestination="true" httpResponseStatus="Permanent" /> </system.webServer> </configuration> |
BONUS
The Handlers part, that quotes GET, POST, PUT and DELETE methods, is to enable them on the project, allowing to use them on the code.