-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fix the server variables in the router_*.php files #16352
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
Conversation
I think you also need to do the same changes in |
Yes, the behaviour is also wrong in prod environment. |
You are right. I have updated the PR. |
What needs to be done here? |
Isn't this something to be fixed in PHP? |
Certainly not. Adjusting the environment variables is done by the rewrite module of your web server. Just look at the existing code:
|
You should change (because of the prod file) the headline of this PR |
Thank you @leofeyer. |
This PR was squashed before being merged into the 2.3 branch (closes #16352). Discussion ---------- Fix the server variables in the router_*.php files | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT The built-in web server automatically rewrites everything to the `app_dev.php` script, but it does not adjust the server variables accordingly. Here is the output of `print_r($_SERVER)` on Apache with mod_rewrite enabled (relevant lines only): ``` Array ( [REQUEST_URI] => /text-elements.html [SCRIPT_NAME] => /app_dev.php [PHP_SELF] => /app_dev.php ) ``` And here is the output of the exact same script on the built-in server: ``` Array ( [REQUEST_URI] => /text-elements.html [SCRIPT_NAME] => /text-elements.html [PHP_SELF] => /text-elements.html ) ``` And here is the return value of Symfony's `Request::getScriptName()` method: ```php // Apache: http://localhost/text-elements.html echo $this->container->get('request_stack')->getCurrentRequest()->getScriptName(); // /app_dev.php // Built-in web server: http://127.0.0.1:8000/text-elements.html echo $this->container->get('request_stack')->getCurrentRequest()->getScriptName(); // /text-elements.html ``` This PR fixes the two server variables in the `router_dev.php` script. Commits ------- 4923411 Fix the server variables in the router_*.php files
👍 |
1 similar comment
👍 |
The built-in web server automatically rewrites everything to the
app_dev.php
script, but it does not adjust the server variables accordingly.Here is the output of
print_r($_SERVER)
on Apache with mod_rewrite enabled (relevant lines only):And here is the output of the exact same script on the built-in server:
And here is the return value of Symfony's
Request::getScriptName()
method:This PR fixes the two server variables in the
router_dev.php
script.