11

Laravel4 framework comes with a default .htaccess rule for create pretty urls.

The rule is this.

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Question: Which is the equivalent in IIS ??

Cœur
  • 37,241
  • 25
  • 195
  • 267
Javier Cadiz
  • 12,326
  • 11
  • 55
  • 76

3 Answers3

8

You can use the import Apache rules feature to convert Apache rule to IIS.

In your case, it will go as:

import

Or in the web.config file:

<rule name="Imported Rule 1" stopProcessing="true">
    <match url="^" ignoreCase="false" />
    <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" />
</rule>
cheesemacfly
  • 11,622
  • 11
  • 53
  • 72
5

This worked for me, thanks to Oli Folkerd:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Laravel4" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
DanielRTRD
  • 63
  • 1
  • 7
2

There are a couple of extra sections that are worth putting in your web.config file

The code below allows you to create restfull controllers using the additional PUT and DELETE HTTP verbs, and allows for laravel's custom error pages to be displayed when you are remotley debugging the server:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Laravel4" stopProcessing="true">
                    <match url="^" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
        <handlers>
            <remove name="PHP53_via_FastCGI" />
            <add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST,PUT,DELETE" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" requireAccess="Script" />
        </handlers>
        <httpErrors errorMode="Detailed" />
    </system.webServer>
</configuration>
Oli Folkerd
  • 7,510
  • 1
  • 22
  • 46