Migrating WordPress From A Subdomain With Easy Way

Last updated December 14th, 2023 10:38

Many WordPress developers often perform website redesigns outside of the main presentation. There are many reasons to do it this way. The new website is placed on the same web server, so there is the same limit and PHP settings, and the website can run online right away. This means that its content can be shown to the client at any time. However, as with everything else, after the work is completed, the data from the subdomain needs to be migrated to the main domain, which comes with certain complications. In today’s article, I would like to take a closer look at how to manually migrating WordPress from a subdomain to a domain work, without plugins. Personally, I am not a big fan of migration plugins when manual migration may not be as complicated as it seems.

Aside from transferring data on FTP from the subdomain folder to the main domain folder (e.g., from the mysubdomain folder to the www folder of the main website), the most challenging part will be modifying the database. In this article, I will take a closer look at that.

Migrating WordPress From A Subdomain With Easy Way

WordPress built on a subdomain has one unpleasant feature. All URL links saved in the database will contain the subdomain name. This needs to be replaced with the main domain name for everything to work correctly. This could include URLs for articles, pages, images, plugin settings, cache modules, and many other things. Rewriting all of these URLs would be impractical in this case. We’ll do it a little faster and better.

The process of migrating WordPress will be as follows:

  • First, we’ll export the database through the phpMyAdmin tool.
  • We’ll open this export in the text editor PSPAD for editing.
  • We’ll use the “replace with” function and replace the subdomain with the main domain.
  • We’ll then import the modified export back into the database.

Exporting the database

Exporting the database is done through the phpMyAdmin tool. I have already described the exact process of exporting the database on the website, and you can find it here. Export the database to an SQL file, which we will modify in the next step.

Editing the SQL file using the PSPAD editor

For editing larger text files, such as database exports, I highly recommend using the PSPAD text editor. It’s free and can handle large files, including database exports that often have tens of thousands of lines. So open the SQL file in the editor and in the top panel, choose the option FIND and then REPLACE after loading it.

The following window will appear, where you will fill in the subdomain name as the item the editor will look for and the domain name it will replace it with wherever it finds it.

Migrace WordPressu ze subdomény na doménu
Migrace WordPressu ze subdomény na doménu

PSPAD will now go through all the exported lines and wherever it finds a subdomain name, it will rewrite its URL address to the domain’s URL address. Once it reaches the end, the modification is complete and you can save the export file.

Migrating WordPress From A Subdomain With Easy Way

Importing the modified file into the database

Once we have the data in the modified SQL file, we can return such a file back into the database. In the phpMyAdmin interface, log in to your database and delete its current contents (I recommend keeping a backup on your local computer). We will be replacing it with the modified one.

Migrace WordPressu ze subdomény na doménu
Migrace WordPressu ze subdomény na doménu

Once the database is empty, we will perform an import of the modified file.

Migrace WordPressu ze subdomény na doménu

The phpMyAdmin tool will complete the import of the modified file, and the entire process of rewriting URL addresses from a subdomain to a domain will be completed.

What to watch out for when migrating WordPress from a subdomain.

Occasionally, after such a change to URL addresses in the database, links on the website, such as in the menu, may stop working. This is not a big problem, and its solution is very simple. Just regenerate the pretty URLs in WordPress.

In the WordPress administration, go to the settings -> permalink settings section. Here, set the links to basic and save the settings. Once the basic settings are saved, revert them back to the original and save the settings again. This will regenerate the URLs in WordPress, and the problem with non-functioning links on the website will be resolved. Now, WordPress built on a subdomain can work flawlessly under the main domain.

If you are using a cache plugin, it is recommended to clear the cache and check whether it has the correct path for storing files. The path to the files should already include the main domain stored in the database (usually https://domain.tld/wp-content/cache).

Migrace WordPressu ze subdomény na doménu

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.


Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Upozornit na
0 Komentáře/ů
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje