Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Can't resolve controllers when '?' is present in the URL on nginx #39

@LewisW

Description

@LewisW

This is an issue affecting usage of PHPCI, using the recommended virtual host settings for nginx, but the bug is in b8framework code so I thought I'd post the issue here.

When a URL contains a question mark on nginx, the method b8\Http\Request::getRequestPath strips the entire request path, meaning the framework can't resolve the URL to a controller. The issue appears to be with how the SCRIPT_NAME is stripped from the path:

        if ($_SERVER['SCRIPT_NAME'] != $_SERVER['REQUEST_URI']) {
            $scriptPath = str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']);
            $path = str_replace($scriptPath, '', $path);
        }

On nginx, the values for these parameters would look something like the following:

  ["SCRIPT_NAME"]=>
  string(25) "/settings/github_callback"
  ["REQUEST_URI"]=>
  string(51) "/settings/github_callback?code=etc"

When the framework strips the SCRIPT_NAME it strips everything but the query string.

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