Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I developed our wordpress site on a subdomain, so I did not disrupt our homepage while I got everything up and running with Wordpress (It was originally running under Orchard, and I needed tochange it).

After the WP site was ready I changed the Wordpress Address general setting to the correct URL, and copied all the files over.

Unfortunately, it seems like this is not all that really needs to be done. Today (quite randomly, since it worked before oddly), images for a part of my site weren't showing up. Long story short it was because all of my WordPress media are pointing to the URL for them on the subdomain, NOT the core domain the site was currently running on.

After doing more research in the database, I can see other references to the subdomain still in the database, such as the posts.guid field in the database for all posts on the site.

What do I have to do to correctly move everything over to my core domain, so when I nuke the subdomain it doesn't affect the main site? I would prefer not having to completely recreate content (like re-upload images) if possible.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

These two pages on the Wordpress codex give a good overview changing URLs:

http://codex.wordpress.org/Changing_The_Site_URL

http://codex.wordpress.org/Moving_WordPress

However to cut a long story short, what I always do is the following:

  1. Back everything up
  2. Copy this handy little file to the root of your site: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/
  3. Run it
  4. It should pick up all of your settings, so all you need to do is enter the old URL as the one to search for and the new as the one to replace it with.
  5. Once that's done you're ready to point the new URL at the site
  6. If you need to, obviously export the entire database to an SQL dump file and copy that and all the web files to the new location

I've never had any problems with this procedure.

A brief word on the searchandreplacedb2.php you downloaded in step 2. Lots of advice is to simply use a text editor to search and replace the old URL with the new URL in the SQL dump file. This will almost always work OK. However it can lead to problems. Wordpress makes heavy use of serialised arrays. If you have a plugin that for some reason stores the site's URL in a serialised array you risk breaking the plugin by doing a simple search and replace in a text editor. See the URL I linked to for further information on this.

share|improve this answer
    
Excellent, thank you very much. I'll mark this as the answer once I get a chance to try it out tonight. –  KallDrexx Dec 2 '11 at 13:23
    
Worked like a charm! Thank you so much! –  KallDrexx Dec 3 '11 at 4:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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