WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#17669 closed defect (bug) (duplicate)

URL is incorrect when trying to post media/image/audio/video

Reported by: AllyUnion Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1.3
Component: HTTP API Keywords:
Focuses: Cc:

Description

Server 1 is running http://www.example.com
Server 2 is running blog.example.com (Word Press site)

Server 1 is on our corporate infrastructure
Server 2 is within the Amazon EC2 cloud.

We generated ProxyPass rules using Apache to implement:

ProxyPass /blog http://blog.example.com
ProxyPassReverse /blog http://blog.example.com

In our Word Press site configuration under Settings > General

We defined
WordPress address (URL) as "http://www.example.com/blog" and
Site address (URL) as "http://www.example.com/blog"

Any time we try to use Post > Add New Post then click on:

Add an Image / Add Video / Add Audio / Add Media

The sub-popup window links at the top for:
From Computer
From URL
Media Library

Are not linked properly. The links we have for them are something like:
"/wp-admin/media-upload.php?post_id=207&type=image&tab=type"

Which is not correct. It should be:
"http://www.example.com/blog/wp-admin/media-upload.php?post_id=207&type=image&tab=type"

If the siteurl is defined, then add_query_arg should rely on get_option('siteurl') to get the proper URL.

I believe this is the fix but I am not familiar with the Word Press code enough to say this is the proper fix:

http://pastebin.com/g3ryWZmD

Change History (9)

#2 @AllyUnion
9 years ago

Along with this file, class-wp-list-table.php needs to be modified on line 478 with:
$current_url = get_bloginfo('url') . $_SERVERREQUEST_URI?;

#3 @AllyUnion
9 years ago

Also line 634:
from:
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVERHTTP_HOST? . $_SERVERREQUEST_URI?;

to:
$current_url = get_bloginfo('url') . $_SERVERREQUEST_URI?;

#4 @AllyUnion
9 years ago

Scratch the last two comments

#7 @nacin
9 years ago

Patches need to be uploaded here, and they cannot be simple unified diffs, you need to use SVN's diff tool.

I don't think this is a bug here. Your server isn't fully configured. If you're going to mess with proxies, then you also need to ensure that REQUEST_URI is repaired.

#8 @merty
8 years ago

  • Component changed from Post Types to HTTP

Even though I actually agree with @nacin, I also think that we need to consider situations where it may not be possible to make necessary changes in the server configuration. I recently came across the same problem on a client's project where I had a limited time to fix and had no access to the server that needs a modification in its configuration. Since prepending the site URL would do no harm to WordPress and actually solve people's problems, I think it should be implemented.

I had to solve this problem quickly, so I put the following to the mu-plugins directory:

function merty_fix_redirect_location( $location ) {	

	if ( '/' == $location[0] )
		$location = site_url() . $location;

	return $location;
}

add_filter( 'wp_redirect', 'merty_fix_redirect_location' );

#9 @SergeyBiryukov
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.