One of the biggest problems you will encounter when moving a WordPress site to a new server, is that you may get Internal Server errors and links to posted images may become broken. Let’s face it: despite being very robust and powerful, WordPress is lacking a clear and easily understandable way to transfer your site from one server to another.
Having recently transferred two of my own blogs built on WordPress from my localhost to my final hosting space has proven to be a rather difficult task, as the information available to do this is long, mostly hidden in content between pages, and distributed over various blogs and help tutorials. This article is dealing with this issue, and this issue alone: moving your WordPress site from one server to another, by following the process of setting up the Webtalk blog.
After installing WordPress on my localhost, and posting my first article, I moved my site live to my server at http://www.webtalk.co.za. Immediately, the site started to exhibit the problems mentioned above:
- The site pages did not display correctly
- Images were not showing in posts
- Viewing the full post resulted in an Internal Server error.
The first and most important thing to do, after changing your database settings, is to change your siteurl variable in your wp_options table to your new URL, in this case, change it from http://localhost/webtalk to http://www.webtalk.co.za. This should take care of the immediate problem that your site pages do not display correctly.
Secondly, to resolve images not showing, you have to run a query on the database to replace all your images’ path from the localhost to the live domain. This could typically look like this: UPDATE `wp_posts` SET `post_content` = REPLACE(post_content, ‘http://localhost/webtalk’, ‘http://www.webtalk.co.za’). You would need to repeat this query also for permalinks and comments, where needed. This will take care of images not showing as they should.
Finally, here comes the kicker: getting rid of that pesky “500 Internal Server Error”.
The WordPress CodeX explains this in a long and windy manner. And here, my friends, is the key to this article. The simple way to resolve the Internal Server Error:
- Go to your site admin, and change your permalink settings to Custom type
- Leave the custom type the same as the previous structure that it was.
- Save your settings. Your page should be displaying correctly now.
Now your question is: WHY does this solve the problem?
The simple answer is that it rewrites your .htaccess file that handles your permalinks. The Codex article explains that you need to remove your .htaccess settings, and provides various other longer descriptions and tips and tricks to get this problem resolved, but the fact remains that this can be resolved by simply faking the change of your permalink settings.