Grow your CSS skills. Land your dream job.

Migrating WordPress from subdomain to root

  • cjk
    # December 14, 2010 at 10:49 am

    Hi,

    I have been thinking about doing this for some time and with Christmas holidays coming up thought it might be a good use of downtime from work.

    I originally setup my wordpress install as http://www.mydomain.com/blog and am thinking now that all of my static pages are handled by wordpress at http://www.mydomain.com/blog and all I am using http://www.mydomain.com for is an entry page, since WP has grown up to be a pretty good CMS, I really should move everything to http://www.mydomain.com

    I have done some reading on this and it appears that there might be more than one way to do it.

    Either way though, there will be plenty of redirection going on to save my current SEO.

    I was wondering if any of the experts here would have opinions on the best way to do this, the pitfalls, the things to watch out for, the preparation etc.?

    Thanks in advance!

    Chris

    # December 14, 2010 at 1:27 pm

    Someone asked this in the WordPress forums:

    http://wordpress.org/support/topic/what-happens-if-you-change-permalink-structure-multiple-times/

    I’ll summarise, it will likely be a headache without a plugin:

    http://www.deanlee.cn/wordpress/permalinks-migration-plugin/

    I have not used this myself, I suggest that once you make the changes check EVERYTHING – posts, pages, media, feeds and strangely wp-admin/

    If it breaks, change it back and reassess…

    cjk
    # December 14, 2010 at 3:42 pm

    Hi Clokey,

    I have read that thread and just had a look at the plugin. I’m not sure this will be the solution I am looking for since the issue is not what I have. The thread and the plugin solve the problem of changing your permalinks but what I wish to do is change where my wordpress installation exists. It exists now in http://www.mydomain.com/blog and I want to move it to my root domain, not just change my permalinks.

    Unless I am thinking too black and white, I can’t see how this would

    # December 14, 2010 at 4:16 pm

    I changed from a ‘subfolder’ to the root of my server and didn’t think of the problem of like this. I did however just try this plugin to see if it could fix the really old links – it failed.

    If you are moving the WordPress index.php, and altering the values on the Admin page (as per: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory ) then it may have to be a .htaccess RedirectMatch moment. I’ll try a few .htaccess approached, to see what happens.

    Could you clarify that you are just shifting all of your URL’s down a directory like I did?

    cjk
    # December 14, 2010 at 9:09 pm

    Clokey,

    I installed my wordpress into the subfolder, now I would like to take it out of the subfolder and put it in the root.

    I think a new install is in order, and then use the importer to bring everything back in to the new installation. Any links that are hardcoded internally to http://www.mydomain/blog/... will have to be changed and of course everything will have to be redirected to maintain incoming links and seo.

    That’s where I am trying to determine the best way to proceed, as I have over 500 pages and images…

    cjk
    # December 14, 2010 at 9:11 pm

    Oh, btw, I found this post which is pretty timely, but not a complete solution for what I want to do.

    # December 15, 2010 at 11:54 am

    So what I am hearing is that you want to move all of your wordpress files out of the directory its in, into the main root folder of your site?

    First of all, back up all your files! You have to move all your wordpress files to the root. Then, you need to go into your database (via phpmyadmin) and change the wp_options table to the new address where your wordpress installation lives; the files under that table that you need to change are the “siteurl” and the “home” file (change http://www.mydomain.com/blog to http://www.mydomain.com). After you do that, then you can log in to your worpress account under the new domain and you will have to reset your permalinks (You may need to do a directory index on your .htaccess file to tell it to use index.php so it will use your wordpress installation as the site). You will also need to replace all your links with the new domain so your images and what not will work. I would use the search and replace plug in (http://wordpress.org/extend/plugins/search-and-replace/). Replace your old domain with the new one on everything. You shouldn’t have to touch your config.php file at all unless your database is changing or moving, but it sounds like you still want to use the same one. That should do it, and hopefully that all makes sense.

    cjk
    # December 16, 2010 at 10:01 am

    AustinKnight -

    Thanks! Yes, this would be one way to accomplish what I am thinking of doing and I have to wonder if it is the best, easiest.

    The other idea that has popped up is to simply leave my installation at http://www.mydomain.com/blog/ and figure out how to strip the /blog/ out of the urls and have my wordpress home page at http://www.mydomain.com without physically moving the wordpress files.

    Under “General Settings” there are two fields:

    WordPress address (URL) which is set for http://www.mydomain.com/blog
    Site address (URL) which is also set for http://www.mydomain.com/blog and this second one is annotated with:
    “Enter the address here if you want your site homepage to be different from the directory you installed WordPress.”

    I visited the codex link on the second option and it really only gives info about going the other way. I’m confused as to what this option does, means.

    Would simply changing this second option to http://www.mydomain.com solve my questions?

    # December 16, 2010 at 11:59 am

    Site address would be the “home” for the site. If the main site was a shop, and wordpress handled a side blog then changing this would change any link ‘home’ to the shop – unless the index.php of your wordpress install was moved as per my last comment.

    I have managed to get my old links working though. But I don’t have a clue how!

    Anything extra in my URL’s get scrapped… i.e. http://clokey2k.com/madeupfolder/2010/12/01/new-site-design-is-here-mostly/ redirects correctly to http://clokey2k.com/2010/12/01/new-site-design-is-here-mostly/

    It may be one of my plugins causing the redirect, but none have been updated?

    May it might be worth just changing the site (try these kind instructions: http://askwpgirl.com/how-do-i-move-wordpress-from-a-subdirectory-to-the-root-directory/) and seeing what happens, if it fails just reverse the procedure!

    Sorry no definite answers…

    cjk
    # December 16, 2010 at 12:10 pm

    May it might be worth just changing the site (try these kind instructions: http://askwpgirl.com/how-do-i-move-wordpress-from-a-subdirectory-to-the-root-directory/) and seeing what happens, if it fails just reverse the procedure!

    That’s the way to do it! Excellent find Clokey, thanks!

    # December 16, 2010 at 12:27 pm

    It’s the same information as provided on the WordPress codex, just worded from the other perspective.

    This is the method I used;

    cjk
    # December 18, 2010 at 8:11 pm

    Clokey,
    how did you handle your redirects? I tried using redirection plugin regular expression setting and put source: /blog/* and target as /
    this caused problems of course since wp-admin lives in /blog/wp-admin so I couldn’t log in, also I got Ajax error on every page. Good news was that every page got redirected… so I am back to square one
    sigh!

    # December 19, 2010 at 7:21 am

    I currently have deliberate redirects set-up and running, other than some handled by the W3 Total Cache plugin… oh and I redirect all of my 404 errors using:

    ErrorDocument 404 /index.php?error=404

    in my root .htaccess.

    Try installing W3 Total Cache, see what happens? (I have run out of real ideas now!)

    cjk
    # December 20, 2010 at 8:48 am

    In the article on askwpgirl it states

    Next, MOVE (do not copy) the index.php file that is in the WordPress application directory to the root directory.

    She goes on to say that you should make a blank index.php in the wordpress application directory, silence is golden

    then,

    In a text or HTML editor, open the index.php file that you just moved and change the location of your wp-blog-header.php to the new location.

    But in the codex it states that you should copy, not move…

    Conflicting instructions…

    Okay, so I followed her instructions because she claims the codex has it wrong. Here is what happens… the site works fine but if I go to http://www.mydomain.com/blog/ I get a blank white page, and if I type in any page like http://www.mydomain.com/blog/about/ etc. I get a blank page. I have redirection (not apache module) installed but nothing is getting redirected.

    So I fiddled, I tried restoring the index.php file in the wordpress install directory (so copy instead of move) making sure that the wp-blog-header path was back to original state.

    Now when I go to http://www.mydomain.com/blog/ this gets redirected to http://www.mydomain.com and any pages like http://www.mydomain.com/blog/about/ etc. also get redirected correctly. Redirections are working automagically…

    Great huh?

    Except… now I get a warning pop up in my firefox browser that says:
    The page at http://www.mydomain.com says:
    Ajax error

    You have to click OK in order to close this.

    So that is a problem that I don’t know how to deal with. I tried to clear my cache in wordpress super cache but that didn’t help.

    cjk
    # December 20, 2010 at 10:05 am

    Found the ajax problem, it is a plugin.

    So to recap, the article at askwp that tells you to move, not copy index.php from your wordpress directory and then create a blank index.php in the wordpress root is wrong, at least in my installation anyway. Perhaps she is right if you are setting up from scratch a new wordpress install but if you are migrating an existing installation from a subfolder to root folder, it appears that you must copy not move as per the codex instructions.

    I am all squared away, my redirects work, my site works, just the plugin is broken and I will contact that author!

    Thanks to all who helped!

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".