Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#55135 new defect (bug)

Media URLs break when migrating WordPress content to different domains

Reported by: brylie's profile brylie Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.9
Component: Export Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

All media assets use absolute URLs when exporting WordPress content, including the domain name and port if present.

When importing the content on a new WordPress installation located at a different domain or port, page/post media fail to render since they point to the previous domain/port.

The hard-coded links require post-processing the XML file for the content to be portable across domains and environments (e.g., development, staging, and production).

Ideally, media URLs in the export file would be relative to the WordPress root, such as described in the following issue from 11 years ago: #17048.

Change History (1)

#1 @SergeyBiryukov
2 years ago

  • Component changed from Import to Export
  • Description modified (diff)

Hi there, welcome back to WordPress Trac! Thanks for the ticket.

Using absolute URLs in the database is a design decision, see Absolute versus relative URLs in the core handbook.

When migrating to another domain, it's often easier to just replace all the site URLs with WP-CLI or other tools like the Database Search and Replace script. With relative URLs, it's true that no replacement is needed in this case, but it gets significantly harder to reliably move the site to a different path.

Apart from #17048, this was also previously discussed or mentioned in #29273, #32639, #34609, #34741, #37723, and #40336. That said, it looks like using relative URLs in the export file specifically has not been discussed before, so I think we can use this ticket to investigate that.

Note: See TracTickets for help on using tickets.