[wp-trac] [WordPress Trac] #60739: Wrong redirection when installing with URI rewrite

WordPress Trac noreply at wordpress.org
Sun Mar 10 22:54:12 UTC 2024


#60739: Wrong redirection when installing with URI rewrite
-----------------------------+-----------------------------
 Reporter:  cfinnberg        |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 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
 <?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
 <?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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60739>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list