WordPress.org

Ready to get started?Download WordPress

Forums

Will images be broken once I update DNS? (6 posts)

  1. cyrjm
    Member
    Posted 1 year ago #

    I'm currently building a site on a new host while the old site is running on it's current host provider. So, to admin it I'm going to ip address/~username. I have never done this before so I'm just trying to anticipate any problems and one of them I'm wondering about is what happens to my images once I update the DNS? Is there an outlined process for doing this? I've got a week to sort it out...

    Cheers,

    JC

  2. acmb3
    Member
    Posted 1 year ago #

    The process I normally take is this:

    Main website: website1.com
    Temp Site: 111.11.11.1 (ip address etc..)

    Change your home & main website url to the ip address in WP. RE-upload or adjust all of your images if you are doing that, if you have already backedup and moved your images then no need to re-upload.

    Make your adjustments being careful NOT to hard code the ip address within the template files of WP.

    Right before you are ready to change the DNS I go into WP and alter my settings from the IP to the real website domain name. Next I open PHPMyAdmin and go to the table "wp_posts".

    I then run a replace command and replace ALL ip addresses with the real website:

    UPDATE wp_posts SET post_content = REPLACE(post_content, '111.11.11.1', 'http://www.website1.com')

    This will replace all hard coded links to images or url's you have in your content to the new site.

    Then alter your DNS and you should be fine. :)

  3. cyrjm
    Member
    Posted 1 year ago #

    Awesome...I will give that a shot. I'm actually starting with a fresh install of WP and all fresh content (as per my clients request) so I'm not importing anything. This site should be easy based on your instructions but I have another client site that we're doing the same thing but there will be hundreds of images so I'm concerned with that one.

  4. acmb3
    Member
    Posted 1 year ago #

    If its fresh then even easier - just make sure you do a replace (BACKUP BEFORE YOU DO ANYTHING THOUGH HAHA) on the content and you will be all set.

    With your other client, backup everything then do a replace for the domain so the images will load.

    Remember though, ALWAYS backup your database before doing a replace like that, if you mess up it can mean hours of work - or a quick import from a file. ;)

  5. cyrjm
    Member
    Posted 1 year ago #

    So, just run that replace command and disregard the first steps you outlined in your first comment?

  6. acmb3
    Member
    Posted 1 year ago #

    In theory yes.

    Once you have the NEW fresh one ready to go right before you swap DNS make sure you go into WP and adjust your general site settings. Then do a replace on post_content to get all those nasty hard coded urls out of there. :)

Topic Closed

This topic has been closed to new replies.

About this Topic