[wp-trac] [WordPress Trac] #55135: Media URLs break when migrating WordPress content to different domains

WordPress Trac noreply at wordpress.org
Thu Feb 10 10:58:11 UTC 2022


#55135: Media URLs break when migrating WordPress content to different domains
--------------------------+------------------------------
 Reporter:  brylie        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Export        |     Version:  5.9
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by SergeyBiryukov):

 * component:  Import => Export


Old description:

> 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.
>
> https://github.com/creativecommons/project_creativecommons.org/issues/225
>
> 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:
>
> https://core.trac.wordpress.org/ticket/17048

New description:

 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.

 https://github.com/creativecommons/project_creativecommons.org/issues/225

 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.

--

Comment:

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

 Using absolute URLs in the database is a design decision, see
 [https://make.wordpress.org/core/handbook/contribute/design-decisions
 /#absolute-versus-relative-urls 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
 [https://interconnectit.com/products/search-and-replace-for-wordpress-
 databases/ 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55135#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list