move WordPress to root

It’s really not that big of a deal.
But sequence DOES matter.
And if you have access to your database via phpMyAdmin, that might be handy in case anything goes wrong, you can fix it. The database doesn’t get moved, but it will hold the URLs we are editing below. However, most people have never used phpMyAdmin and you probably don’t need it either. If you did step one correctly.

Step 1) Make a backup of your site. I’ve been using UpdraftPlus and it is awesome. Even the free version is great. Easy to back up, easy to restore. Tons of features. So awesome I paid for it.

What it looks like BEFORE we move anything
What it looks like BEFORE we move anything

2) Clear out any cruft from the root of your web dir- leaving only your wordpress files in the same folder and path they were in. Do not yet move any of your wordpress files. But do move everything else out of the root folder, including any index.html or index.php files. If anything needs to stay at the root, you can put it back in a sec, but for now move it elsewhere.

3) Login to WP as an admin. Deactivate your caching plug-in. Purge all caches now. – If your WordPress site is broken (already?!) you may have accidentally moved the wordpress files too soon. Put them back & try step 3 again.

4) Go to Administration -> Settings -> General.
Change the WordPress Address from example.com/wordpress to example.com
Change the Site Address address from example.com/wordpress to example.com
As soon as you save this change – Boom! – you’ll get an error. That’s how you know it worked! :-) Don’t worry, were are about to fix it.

5) Using FTP, move all the WordPress files (but not the enclosing folder) from their “wp” directory (folder) into root of the web folder.

Nice & clean AFTER we've moved WordPress to root folder
Nice & clean AFTER we’ve moved WordPress to root folder

You will now have a root dir full of all the WP files that used to be in the WP dir.

6) Log into your WordPress at example.com/wp-admin  Hopefully it totally works. ;-)
Just to be sure, Check Administration -> Settings -> Permalinks to ensure the link structure is still good. Push the “Save” button. And Again. Thanks.

7) A few things may still need fixing, like maybe the header graphic. You can relink or reupload.

8) You *may* need to open each page or post & and in the “text” mode, Find/Replace the old URL with the new URL (from step 3 above). For example, if your old WP site URL was example.com/wp/ and the new URL is example.com you’d do a find/replace in the “text”view of each post for example.com/wp/ and replace with example.com/   (those slashes are not optional). I would copy the entire post (from text mode) then paste into a text editor (no MS Word! Please), Then do that Find/Replace. Copy from the Text Editor and paste back into the post. Repeat for each post that has a link problem (they all might).

There are plugins that can quickly do a Find/Replace over your whole site, and this is a great time to know about a good one. I’ve used the free version of All-in-One WP Migration (once) and it did the job by exporting the database, doing your find/replace and offering the db as a download. You then upload it back in as an “import” to make the changes real. You DO have a back up, right? Actually, it did a great job.

9) If your site still needs some of the files you moved out of the root folder, you can put those back into the root folder now, but really consider which files you actually need, and which will just be more clutter to figure out later.

Advanced Tip: If you are not quite ready to go live with the WordPress site yet, you can put your old index.html file (& supporting files) back into the root folder because index.html usually has priority over index.php so your old site can still be at root, and when you want the WordPress site to take over, just rename or remove that index.html file to make the WP site active. This is messy, but does work if you are careful. Sometimes I’ll move all files out of the root folder prior to installing WordPress for the 1st time. Then put them back so the old & new sites can co-exist.  You will need to remember to rename either index.html (z_index.html) or index.php (z_index.php) to make either the old or new site active.

If I left anything out, web search for “move wordpress to root”

Best,
Dave Nathanson
Mac Medix

Leave a Reply

Your email address will not be published. Required fields are marked *