Skip to content

Router error on IIS 8.5 #397

@danutavadanei

Description

@danutavadanei

After configuring lumen and adding a web.config for IIS 8.5 it'll trigger:

[2016-04-06 16:51:06] lumen.ERROR: exception 'ErrorException' with message 'Undefined index: REQUEST_URI' in C:\inetpub\wwwroot\sapxtractor\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php:674
Stack trace:
#0 C:\inetpub\wwwroot\sapxtractor\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(674): Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(8, 'Undefined index...', 'C:\inetpub\wwwr...', 674, Array)
#1 C:\inetpub\wwwroot\sapxtractor\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(404): Laravel\Lumen\Application->getPathInfo()
#2 C:\inetpub\wwwroot\sapxtractor\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(371): Laravel\Lumen\Application->parseIncomingRequest(NULL)
#3 C:\inetpub\wwwroot\sapxtractor\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(327): Laravel\Lumen\Application->dispatch(NULL)
#4 C:\inetpub\wwwroot\sapxtractor\public\index.php(28): Laravel\Lumen\Application->run()
#5 {main}

My server indeed doesn't have REQUEST_URI index but I don't have this issue on laravel.

I added this in app.php and it works:

if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
}

My web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.php" />
            </files>
        </defaultDocument>
        <rewrite>
            <rules>
                <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>
            </rules>
        </rewrite>
        <httpErrors errorMode="Detailed" existingResponse="PassThrough" defaultResponseMode="ExecuteURL" />
    </system.webServer>
</configuration>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions