Skip to content

Request URI is incorrect when run under php-fpm/fastcgi #188

@frisket

Description

@frisket

When I moved my application from using the standard apache mod-php5 to one run by php-fpm (for performance reasons), I discovered that Tonic subsequently failed to correctly parse the request URI.

The getURIFromEnvironment() in Request.php first looks for $_SERVER['REDIRECT_URL'], and if that exists, uses it for the request URI.

This may be correct when run within apache, but under fpm, it returns the URL to the dispatch script instead.

eg:
Original request: http://localhost/myapp/web/category

In Apache:
$_SERVER['REDIRECT_URL''] is '/myapp/web/category'

In FPM:
$_SERVER['REDIRECT_URL''] is '/myapp/web/dispatch.php'.

I would recommend that Request.php check for $_SERVER["REQUEST_URI"] first instead of $_SERVER["REDIRECT_URL"], as it always seems to contain the correct URI that's needed.

I've hacked around this issue temporarily by overwriting $_SERVER["REDIRECT_URL"] with $_SERVER["REQUEST_URI"] in my dispatch.php, but having this handled in the base code would be great!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions