Opened 9 months ago
Last modified 7 months ago
#60739 new defect (bug)
Wrong redirection when installing with URI rewrite
Reported by: | cfinnberg | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 3.7 |
Component: | Upgrade/Install | Keywords: | |
Focuses: | Cc: |
Description
I have a server where the users can build their own WordPress installations. The URL of such installation is like: https://example.com/u/user/wpfolder/
The folder on disk is like: /srv/http/public_html_user/wpfolder
But when the user tries to run the installation setup, an automatic redirection leeds to the following incorrect address: https://example.com/wpfolder/wp-admin/setup-config.php (notice that /u/user/ is missing)
So:
- REQUEST_URI is '/u/user/wpfolder'
- My document root is '/srv/http/public_html_user/'
- Therefore the document URI (relative to this document root) is '/wpfolder/index.php'
- And the $_SERVER[PHP_SELF] value is '/wpfolder/index.php'
I have found that the problem comes from the wp_guess_url function in wp-includes/functions.php file (line 6218):
<?php ... } elseif ( $script_filename_dir . '/' === $abspath_fix ) { // Strip off any file/query params in the path. $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); } else { ...
I'm not sure am I missing something, but in my opinion path should use REQUEST_URI:
<?php } elseif ( $script_filename_dir . '/' === $abspath_fix ) { // Strip off any file/query params in the path. $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ); } else {
This only occurs if a rewrite of the URI has happened, as in my case.
Hi @cfinnberg, welcome to WordPress Trac.
This code was introduced in [25396] as a part of 3.7 so updating the version to match.