Why does WordPress rely on an fully qualified site_url with a 15-step plan for moving a site?

From the Moving WordPress codex page (emphasis mine):

When your domain name or URLs change there are additional concerns. The files
and database can be moved, however references to the old domain name
or location will remain in the database, and that can cause issues
with links or theme display.

If you do a search and replace on your entire database to change the
URLs, you can cause issues with data serialization, due to the fact
that some themes and widgets store values with the length of your URL
marked. When this changes, things break. To avoid that serialization
issue, you have two options:

  1. Only perform a search and replace on the wp_posts table.
  2. Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this
    option. It is a one step process as opposed to
    the 15-step procedure
    below )

What are the benefits of saving the site_url vs. using relative links? Is it because of performance? Or is there some other benefit (e.g. SEO-related or technical) when hyperlinks in the content are fully qualified?

Because it certainly makes WordPress more difficult to use when developing in a team, when you have a shared database with your test/acceptance environment, and when ‘going live’ with a WordPress website.

1 Answer
1

This question has been discussed several times on the WordPress Hackers email list, I’d recommend Googling something like wp-hackers absolute relative to get an overview of the various lively debates that have taken place over the years.

Personally I use the searchreplacedb2 script whenever I migrate a database between URLs, e.g. from live to local/test/dev.

Leave a Comment