Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
frisket opened this issue Feb 24, 2015 · 1 comment
Open

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

frisket opened this issue Feb 24, 2015 · 1 comment

Comments

@frisket
Copy link

frisket commented Feb 24, 2015

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!

@peej
Copy link
Owner

peej commented Feb 24, 2015

I've had problems getting the environment order correct to work for all servers, I can't remember how we arrived at the current ordering.

You can pass in the correct request URL when you create the Request object within the dispatcher.

It'd be great if you could add this and test it against mod_php. Ensure that you also update the Request object spec. Let me know if you need some help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants