The goal is to make my hidden Wordpress site go from http://example.com/subdir (which I have now) to replace the olde site at http://example.com (which is what I want when I take my WP site live). In previous questions this article came up in regard to changing the URLs: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

My old example.com URL points to the old html site while the /subdir Wordpress site is new and improved. The plan is to institute an instant and permanent switch to the Wordpress site in the subdirectory, but to use the example.com main directory as the link.

The problem I have is that there are a lot of links within my wordpress site to http://example.com/subdir/page1 and http://example.com/subdir/page2 and so on. Will that be a nightmare to clean up manually or will link change to become http://example.com/page1 once the switch is made, making the "/subdir" mention completely disappear? Is there any software or a plugin that can just do a global URL update across my site so every http://example.com/subdir/page just becomes http://example.com/page automatically?

I'm getting nervous as it comes time to take it live and I've never done this kind of thing before. Please let me know what I can expect when everything changes over and what will make it as easy as possible. Thank you!

2 Answers 2


You can search and replace every occurence of "http://example.com/subdir" in the database with "http://example.com".

If you're comfortable with WP-CLI, there is command for that:

$ wp search-replace 'http://example.com/subdir' 'http://example.com'

If not, you can use some plugin for that. Some possible would be:

  • 1
    I took the liberty of adding another plugin, which is extremely simple and has done a great job many times for me. If you mind, just remove my edit
    – kero
    Sep 3, 2018 at 3:26

Another choice is to just set the domain to the new folder. This is done in your hosting Cpanel, under domains and/or add-on domains. Check your hosting's help pages for how to direct a domain to a folder other than the 'root' folder (often called 'public_html').

Otherwise, you will need to copy all files from the subdir folder to the root - all WP files, themes, plugins, custom code, media, etc. Then you will need to do a search/replace of the old url to new url. I use the "Better Search and Replace" plugin to do this.

So it might be easier just to use your hosting processes to point the domain to the new folder.

Your Answer

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

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