WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Moving WordPress (15 posts)

  1. peredur
    Member
    Posted 2 years ago #

    A client has asked me to move her WordPress site to a new host, keeping the same domain. I've never done this before, so I'm a bit nervous. Correction: I'm a lot nervous.

    The Moving WordPress instructions don't quite add up for me. Firstly they say:

    Moving your domain without changing the Home and Site URLs of your WordPress site is very simple, and in most cases can be done by moving the files.

    I understand I'll have to edit wp-config.php for the database connection details, but that's OK.

    Then the instructions say:

    If you had any kind of rewrites (permalinks) setup you must disable .htaccess and reconfigure permalinks when it goes live.

    I'm not sure if this is a comment that applies in all situations, or just in the "test before you switch" situation (I do use pretty permalinks, btw). The paragraph is contained in that list item. And what do they mean by "Disable .htaccess"? Do I delete it? Will that mess up anything the host has put in there? Do I just need to comment out a rule?

    I don't really understand the "Try before you switch" option, either. What would I change the URL and Address to, since they're not going to change, according to the section heading? And if you look at the instructions for when the URLs do change, it's a heck of a lot more complicated than just temporarily changing the site URL and Address.

    Then the instructions say:

    If you are changing to a new server but same domain, all you need to do is edit wp-config.php with your new database/user information and upload everything as it is to your new server.

    This is my case, I imagine. I would have thought it would be true of all cases in this section since if the URLs are not going to change I would have thought the only possible change would be to the server. But maybe I'm missing something. So do I ignore the instructions given above this paragraph and just copy the WP files and a db backup to my local box, edit wp-config for the database changes, and then upload everything to the new host?

    Maybe I'm making a fuss over nothing, but I really do have to get this right.

    Cheers

    PAE

  2. cjc1867
    Member
    Posted 2 years ago #

    I have moved a few WordPress sites before and I normally install a new version of WordPress on the new server. By doing it this way ensures that the database is set up and configured for that installation.

    Back up the website folders that contains the files you need like themes,plugins,media etc and I then back up the MySql database via PhpMyAdmin. Also back up using export from within WordPress just in case under Tools => Export. Export will save all your pages and posts but doesn't save any images etc.

    The MySql back up will save all WordPress settings so you shouldn't have to reconfigure the new WordPress site. On the new server, go to phpmyadmin and select the database and import your MySql backup you made earlier using phpmyadmin. Before I imported the database I made sure there wasn't any posts, pages, categories set from the new installation as it might cause errors and duplication.

    Copy your folders to the same directory structure on the new server and you should be done.

    I haven't perfected it yet but anything isn't right I have just had to fix it there and then. I did start off first and created a local copy using WebMatrix first so that I could iron out any problems that I might encounter on the way.

  3. govpatel
    Member
    Posted 2 years ago #

    Doing what cjc1867 suggested is fine make sure you install the same version wordpress or update.

    When importing database in new install on new server you need to drop all tables and then import database.

  4. cjc1867
    Member
    Posted 2 years ago #

    Who said 'suggested' it's how I do it and perhaps not perfect but it gets the job done.

    Nice tip, I will certainly drop all tables in future before I import the database that way I don't have to delete pages, posts etc.

  5. peredur
    Member
    Posted 2 years ago #

    Many thanks for your answers.

    @cjc1867: Could you explain what you meant by this:

    Before I imported the database I made sure there wasn't any posts, pages, categories set from the new installation as it might cause errors and duplication.

    I'm not sure what you mean by having posts set, or pages set. The site I'm trying to transfer has loads of posts, pages, categories and stuff.

    @govpatel: thanks for the tip about the versions. I would have missed that.

    Cheers

    PAE

  6. govpatel
    Member
    Posted 2 years ago #

    If you follow @cjc1867 post and install a fresh wordpress then all you will need to do is
    Replace wp-content folder from the old server
    Export your database from old server
    Drop all tables from new install on your new server
    Import your database on new server
    Reset your permalinks

  7. cjc1867
    Member
    Posted 2 years ago #

    I mean the new WordPress, it adds a few sample pages and posts. When I imported the backup via phpmyadmin it gave duplicate errors so I found that deleting these first didn't cause any errors.

    But as @govpatel said you can drop the tables first before importing the backed up one, which was a good tip that I will do now in the future. It saves deleting the page and post.

    The sites I have moved though were already upto date, version wise so again a good tip by @govpatel.

  8. peredur
    Member
    Posted 2 years ago #

    Thanks both. I think I'm getting there. But what's this about resetting permalinks? Will I have to mess with .htaccess for that and if so, what do I have to do?

    Or do I just go into the settings and set them to what I had before?

    Cheers

    PAE

  9. govpatel
    Member
    Posted 2 years ago #

    But what's this about resetting permalinks? Will I have to mess with .htaccess for that and if so, what do I have to do?

    Since you will have new install your .htaccess file will not have any code so all you need to do is click on Settings>>>>Permalinks use the same setting you used on old server and save.

  10. peredur
    Member
    Posted 2 years ago #

    Oh! I was planning on uploading the whole old site, since I have it backed up and since I have a database already set up. Changing the wp-config file to conform with the database isn't a problem.

    Should I not transfer the .htaccess file? Or should I just create an empty one?

    Or will uploading the backed up .htaccess file automatically set up the permalinks correctly?

    Cheers

    PAE

  11. cjc1867
    Member
    Posted 2 years ago #

    Have you got any special rules in there? I didn't have to touch that file and I don't know enough to mess with it. One is created anyway.

  12. peredur
    Member
    Posted 2 years ago #

    No. I've not put anything in there myself. It'll presumably just contain the rules put there by WP for the purpose of pretty permalinks. In fact it says the following:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Just appears to be checking the path and if the path doesn't point to a file or a directory, redirect to index.php.

    The host doesn't appear to have installed one on the new site.

    I'm not to well up on .htaccess file, either, which is why I'm enquiring.

    Cheers

    PAE

  13. cjc1867
    Member
    Posted 2 years ago #

    Mine is very similar to yours but my installation is in a directory and that's the only difference.

    .htaccess file is there but it might be hidden from your view.

  14. peredur
    Member
    Posted 2 years ago #

    OK. I'll upload everything (including .htaccess) and see what happens. I imagine I could delete it if I had to.

    I should be able to see it btw, because I've set FileZilla to display hidden files.

    Thanks for all your help. I'll post again after I've made the move (probably next week, now) to say how I got on and, hopefully, mark the topic as resolved.

    Cheers

    PAE

  15. peredur
    Member
    Posted 2 years ago #

    Worked a treat. Thanks to both of you.

    I just:

    • modified wp-config.php for the new database details
    • imported the database from an export (.sql file) stored on my local machine, to the new host. I had to do it by pasting the SQL into the SQL box in the new host's version of phpmyadmin as their version of phpmyadmin didn't provide an "Import" option. It worked fine, though
    • FTPed the backup of the wordpress site (including the .htaccess file) from my local box to the new host

    Then I just visited the site and everything was just as it had been - pretty permalinks and all.

    Thanks again. Brilliant. And a big relief.

    Cheers

    PAE

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.