0

I have a wordpress multisite installation which uses subdomains for subsites. However, I have received request that I have to change the domain of one of the subsites from e.g. site1.example.wordpress.org to some other e.g. crafting-jewelry-1.com. I’ve found this link that explains that top level domains for subsites can be changed, upon installation in the wp-admin:

How to use Wordpress Multisite With Different Domain Names?

But my site has been in use for some time, stuff likes themes and plugis have been changed from defaults, and it have active users. If I follow the instructions from the answer above, and change the URL for a subsite, will this break the site? Do I need to make a manual change somewhere in mysql or wp-config.php?

My wp version is 4.9.4 . Note that I do not want to change the multisite original domain, just a domain of one of its subsites. I have tried “changing” the domain by using a reverse proxy through apache, however, even if I get the desired url in the browser, the page is dynamically generated with the links to the old domain, and when I follow any of them I am naturally redirected to the old domain.

1 Answer 1

1

This question is getting a little old, but since I came across it looking for other related things I thought it deserved an answer. The answer provided on that other link you included is actually the spot-on correct answer here too. It goes into more detail, but I will summarize here.

What you want to do is called domain mapping. A while ago in previous versions of WPMU / Multsite this had to be accomplished using a plugin. Now, it's baked into the setting called "Site Address (URL)" for each subsite in Network Admin > Sites > Edit [site] > Info [tab]

Changing the Site Address (URL) of a subsite will not affect the main site URL or other subsite URLs. The thing to keep in mind is that WordPress controls serving content to those configured URLs, but it's critical to make sure that DNS A Records are properly pointed to the server for any domains you want to map to subsites. All those domains will have the same IP address in DNS, and then once the requests for a particular domain / URL hits WordPress it will serve the correct content based on what is configured for Site Home and Site URL settings in the database.

Other than changes in DNS to point the domain to the right IP you do not need to do anything fancy with apache or reverse proxy.

Changing the Site Address (URL) setting of a subsite will not break anything on the site (assuming you have properly used relative URLs for everything). Note that some themes and plugins might store a static URL for some settings or images in the database, which will indeed break.

However, there is a very easy fix for that. Use a plugin like Better Search and Replace to easily find ALL entries of site1.example.wordpress.org and replace to crafting-jewelry-1.com

Using the full domains you want to update there will only target things that should be replaced and this will happen across your database. There are different opinions on this, but when I'm doing a rename like this I also turn the option ON to replace GUIDs as well. However, you should understand the implications of doing that or just leave that option OFF.

Naturally, take good backups before doing any of this in case something does not go as expected.

In a nutshell:

  1. Make sure DNS is pointing the domain you want to use at the IP address where WP multisite is installed.
  2. Update the Site Address (URL) setting for the subsite you want to change
  3. Run Better Search and Replace on the old subsite domain to the new subsite domain (it's default mode is a dry run which does not actually make changes but lets you see how many replacements it will make).

Additional, good details are here as referenced in the question:

How to use Wordpress Multisite With Different Domain Names?

1
  • Thanks, but since issue was critical I've resolved it soon after I posted the question. I've tried changing the options like in the link described above and searched and replaced everything in database, but that didn't work for some reason. Then, after backup restoration, I've took similar approach as you described: domain mapping, but with a plugin. I didn't know that domain mapping is incorporated in wordpress now. Thank you! Hope you have a very nice day!
    – Gitnik
    Jun 25, 2018 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.