简体   繁体   中英

Wordpress - trouble with migrating site from subdomain to root

I was developing a wordpress site on a subdomain and now I'm ready to place it on the main domain. However I'm having trouble doing this. I was following the instructions at: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install

But the problem comes when I'm supposed to rewrite the <?php require('/wp-blog-header.php'); ?> <?php require('/wp-blog-header.php'); ?> If I change it to <?php require('_sub/wc/wp-blog-header.php'); ?> <?php require('_sub/wc/wp-blog-header.php'); ?> it gives me error: require() [function.require]: Failed opening required '/home/tr006600/www_root../_sub/wc/wp-blog-header.php' (include_path='.:/usr/share/pear/') in /home/tr006600/www_root/index.php on line 17.

I think the problem is that at my provider, the subdomain folder isn't located inside the www_root, but is a totally separate folder. I've also tried this <?php require('http://wc.example.com/wp-blog-header.php'); ?> <?php require('http://wc.example.com/wp-blog-header.php'); ?> but didn't solve the problem either.

Any ideas how to fix this issue, please?

Treat the install as its own site and as a separate domain. Basically what you want to do is copy all of the files in the sub domain to the root domain and update the DB to change the URLs in the setting and posts/pages. Below are the MySQL queries you want to run if you are using the default table prefix.

UPDATE wp_options SET option_value = replace(option_value, 'http://sub.domain.com', 'http://www.domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, 'http://sub.domain.com', 'http://www.domain.com');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://sub.domain.com', 'http://www.domain.com');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://sub.domain.com', 'src="http://www.domain.com');
UPDATE wp_posts SET  guid = REPLACE (guid, 'http://sub.domain.com', 'http://www.domain.com') WHERE post_type = 'attachment';
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://sub.domain.com','http://www.domain.com');

More information here: http://codex.wordpress.org/Changing_The_Site_URL & http://codex.wordpress.org/Moving_WordPress#When_Your_Domain_Name_or_URLs_Change

Next time you want to move a WordPress site, you can consider using a WordPress plugin to handle the job for you.

There is several plugins that can do this for you.

Check this one : Golive

GoLive Features:

  1. Automatically Export the Database from Source Server

  2. Transfering the files via FTP automatically

  3. Auto-import Database in Remote/destination server.
  4. Update .Htaccess properly
  5. Update wp-config.php file on destination server with the new credentials.

  6. Replace the URLs in Database (Posts, Pages, Menus…), and keep auto-update serialized objects too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM