0

I'm developing a Wordpress site for a website that already exists (that's not currently using Wordpress). The current website cannot be taken down until the new Wordpress site is ready to replace it. I've read the Moving Wordpress codex article and the Giving Wordpress it's Own Directory codex article but I cannot decide, and do not have enough experience to know, which method would be easier/more efficient when it's time to make the website switch?:

Option 1: Develop the website in a subdomain (ie: http:// wordpress.website.com)

Option 2: Develop the website on a 2nd, temporary domain (ie: http:// w3bsite.com)

Any advice from those who have done either would be appreciated.

P.S. The site has already been built locally, using Xampp, but now needs to be deployed online so others involved in the project can populate the site with content.

1 Answer 1

0

I would prefer Option 1, that is deploy it on a subdomain. Once contents are filled up you just need to do 2 things.

  1. Move the files to root directory of main domain. Using hosting's File Manager, it would take 1-5 sec.
  2. Change the WordPress Site URL to your main domain. You can following method to change it without running a SQL Query (fetched from Moving WordPress)

wp-login.php can be used to (re-)set the URIs. Find this line:

require( dirname(FILE) . '/wp-load.php' );

and insert the following lines below:

//FIXME: do comment/remove these hack lines. (once the database is updated) update_option('siteurl', 'http://domain.name' );

update_option('home', 'http://domain.name' );

If you have internal links (links in your post/page contents that links to your temporary subdomain URL), you can either update them manually or run a SQL query to update them all.

Update: To update the internal links you can run following SQL queries.

To update the links in page contents

UPDATE wp_posts SET post_content=(REPLACE (post_content, 'sub.domain.name','domain.name'))

To update the new domain name in post meta

UPDATE `wp_postmeta` SET `meta_value` = REPLACE( `meta_value` , 'sub.domain.name','domain.name'); 

Above Step 2, can also be accomplished with following query.

UPDATE wp_options SET option_value = 'http://domain.name' WHERE option_name IN ('siteurl', 'home')

if you have Database prefix other than "wp_" please change the table names with your prefix.

6
  • That information is from the "If you have accidentally changed your WordPress site URL" section - wouldn't I want to avoid any "accidents"?
    – codeview
    Commented Nov 18, 2013 at 18:39
  • Well, that heading follows the method above it. We are not following the long method it describes. In our case, I outlined above, this will work without accidents.
    – M-R
    Commented Nov 18, 2013 at 19:53
  • Would links to photos (uploaded through Wordpress) also be broken, same as links within pages/posts? The goal is to not have anything broken when the Wordpress website replaces the current website, so SQL queries are the scary part, I guess.
    – codeview
    Commented Nov 18, 2013 at 20:33
  • Updated the answer to fix the internal links. Most SQL queries are not that scary, I use the above queries every next day.
    – M-R
    Commented Nov 18, 2013 at 21:27
  • Does the update query on wp_posts include custom posts? I will have 4 custom post types to worry about too. There must be a better way than having to do a bunch of SQL queries :(
    – codeview
    Commented Nov 18, 2013 at 22:57

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.