A question often asked is how to change the URL of their WordPress site.
Here’s a common scenario: you install WordPress into a sub-directory on your web server so you can create a theme, upload content, and test it without interrupting your current site. There’s nothing wrong with doing it this way. In fact, this is how a lot of people develop and test websites before launching, myself included. One problem many people run into after switching their homepage to point to the sub-directory you installed WordPress is that many of the URLs still use the sub-directory instead of the root.
Let’s look at an example.
- Current site URL: http://mywebsite.com
- WordPress Development URL: http://mywebsite.com/wordpress
At some point development stops and you are ready to switch your homepage so that it’s using the /wordpress/ directory. However, you notice that something isn’t quite right. Perhaps the links to your posts are going to the old development URL? Perhaps your theme was dependent on the old URL and the header image is broken?
This is fixable in two easy steps.
Update URL in WordPress admin panel
The first step is to login to the admin and go to Settings -> General. Update the WordPress address (URL) and Site Address (URL) options from http://mywebsite.com/wordpress to http://mywebsite.com.
Run MySQL query to update content
The next step is to run a MySQL query. If you aren’t familiar with SQL, contact your host or IT support to see if they can run it for you.
UPDATE wp_posts SET guid = REPLACE (guid,'http://mywebsite.com/wordpress','http://mywebsite.com'); UPDATE wp_posts SET post_content = REPLACE (post_content,'http://mywebsite.com/wordpress','http://mywebsite.com');
Once you have completed these steps, all URLs should be updated.
If you are performing more complex moves such as moving the database to a different server or moving the WordPress files around, check out these articles on the WordPress Codex: Moving WordPress and Changing The Site URL.