Support » Fixing WordPress » Migrating WordPress site to new server and new url

  • silentecho

    (@silentecho)


    Hi
    I am running WordPress 5.7.2 and I am moving existing Installation to new server and new url (a different main website name).

    I have transferred all WordPress system files, created a new database and imported the tables. I have also changed the values of siteurl and home in wp-options table.

    But as soon as I access the new install it opens the old url. Same with wp-admin – I go to new site type domain name or domain name/wp-admin and it switches to original url.

    There must be another setting somewhere that needs changing but I cannot find it

Viewing 13 replies - 1 through 13 (of 13 total)
  • barnez

    (@pidengmor)

    Use a plugin like https://wordpress.org/plugins/better-search-replace/ to search the database and replace all instances of olddomain.com with newdomain.com.

    Thread Starter silentecho

    (@silentecho)

    OK, problem there is

    I cannot run on new installation since the dashboard switches back to the old one.

    If I run it on old installation, that will stop working as well

    barnez

    (@pidengmor)

    An alterative is to export the database as an .sql file. Open the file in an editor like Notepad++. Then do a find and replace for all instances. Finally, import back to the database.

    Thread Starter silentecho

    (@silentecho)

    Too big, have to do table by table, also I have some links to content I want to keep. I know you are trying to help, just a shame WordPress does not document / allow for this.

    There must be some value called as site is accessed, without having to change every occurrence

    • This reply was modified 5 months ago by silentecho.
    barnez

    (@pidengmor)

    How about using a MySQL query:

    update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to search, 'Text to replace it with');

    https://kinsta.com/knowledgebase/wordpress-search-and-replace/

    Thread Starter silentecho

    (@silentecho)

    OK ALL references to old site changed in database, approx 7000 references replaced, performed new check by searching in PHPMyadmin – database contains NO references to old domain.

    Same result – still redirects to old url when loading site or wp-admin !

    barnez

    (@pidengmor)

    What do you see in the main .htaccess file? Are there any remenants of the old url that need updating e.g. in https redirects? Are there any plugins that might be caching the old urls? You could try disabling them through MySQL (https://www.siteground.com/kb/how_to_disable_all_wordpress_plugins_directly_from_database/). Clear the browser browser cache and/or try accessing the site in an incognito window?

    Thread Starter silentecho

    (@silentecho)

    In frustration I have deleted .htaccess, disabled all plugins in database, deleted all plugins in plugins folder and deleted current template

    Opened in new private/incognito window – same result !

    barnez

    (@pidengmor)

    Where is the domain hosted? Check that the registered domain points to the correct url.

    Thread Starter silentecho

    (@silentecho)

    Yeah it is pointed ok https://domain.com works ok, this is main site, it is only when I try to access WordPress which is in https://domain.com/info that it redirects to original wordpress site

    Websites Seller

    (@websitesseller)

    First of all, clean your browser. This simple detail may cause the issue.

    SQL:
    After you created&configured the db (change the values in wp-content.php, import the old .sql), add these lines into phpMyAdmin (SQL):

    UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
    
    UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
    
    UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
    
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

    Same, in the database, go to wp-options -> Edit siteurl and home with the new values.

    After that, before accessing the Dashboard, clean your browser again. Then go to WordPress Admin Dashboard -> Settings -> General and make sure the URLs are corresponding.
    If everything is ok, go to Permalinks and click Update.

    Last: Install this plugin and configure everything there (change old url with the new one): https://wordpress.org/plugins/velvet-blues-update-urls/

    Thread Starter silentecho

    (@silentecho)

    OK @websitesseller
    I am going to start from scratch and work my way through your suggestions, I will delete all new wordpress files folders and database and start with new install / transfer from the old domain – wish me luck BUT –

    ‘(change the values in wp-content.php, import the old .sql)’ – did you mean wp-config.php ?

    Websites Seller

    (@websitesseller)

    Hello silentecho,

    Before deleting anything, make sure you have a backup. The wp-config.php is the file which connect the WordPress files with the .sql database. By default, you will see it named as “wp-config-sample.php”. To make it works, rename “wp-config-sample.php” to “wp-config.php” (just delete the “-sample” from the name of it). Now you will have to files: wp-config.php and wp-config-sample.php (you can delete the sample file).

    (Assuming you’ve just created a new blank database and imported the old database information into it) – After that, open/edit the file. You will have to edit the following lines:

    Database Name – Database Name used by WordPress
    Database Username – Username used to access Database
    Database Password – Password used by Username to access Database
    Database Host – The hostname of your Database Server. A port number, Unix socket file path or pipe may be needed as well.

    -> Here, you can let it as default – ‘localhost’.

    It’s not something difficult to do, but you have to pay just a little attention to the details.

    You can find more information about how to edit the wp-config.php, here: https://wordpress.org/support/article/editing-wp-config-php/

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.