Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#44653 closed defect (bug) (invalid)

wp_upload_dir not obeying HTTPS and forces everything to HTTP

Reported by: son9ne's profile son9ne Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords: reporter-feedback
Focuses: Cc:


This is a follow-up to #34945.

Bug is still present in 4.7.9. This has even been noted on the docs and a work-a-round is there too:

This is due to a bug with: wp_upload_dir

When using HTTPS it is expected that wp_upload_dir() will respect the protocol, but it is always returning HTTP for URLs.

To test: setup an HTTPS site then use this in a plugin/theme. It will always return HTTP for the URLs

Change History (5)

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

5 years ago

#2 @SergeyBiryukov
5 years ago

  • Keywords reporter-feedback added

Hi @son9ne, welcome to WordPress Trac!

What are your WordPress Address and Site Address in General Settings?

Related: #33092, #44636.

#3 @son9ne
5 years ago

Thank you!

I am using the constants:

define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wordpress');
define('WP_HOME', 'https://' . $_SERVER['SERVER_NAME']);

Just to be safe, I also checked the options table to ensure it is using https:// as well and it is.

#4 @son9ne
5 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Ok, after looking more into this issue. It seems this is due to a special setup I have. I am using a single install of WordPress to serve numerous sites. Each site has it's own wp-content and this is defined in their configs.

The issue here is that I needed a global config due to how WordPress steps out a directory to locate the config file. This has a constant using http:// which is not obeying the protocol. I am then assigning that custom constant to WP_CONTENT_URL and that seems to be the culprit.

I have not tested this theory but I feel pretty confident that is the issue. I saw the issue on the docs so immediately assumed. I should have spent more time looking into this. Sorry to waste your time.

Last edited 5 years ago by son9ne (previous) (diff)

#5 @netweb
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.