7

I have moved one of my website to a new domain, below is what i did.

  • Backed up database
  • Uploaded all the files to the new server.
  • Imported sql into new server via phpmyadmin
  • Now i have used this script to change URL in database.

Now, problems i am facing are:

  1. All the links are going to old domain.
  2. All the images are linked to old domain.
  3. wp-admin is also redirected to old domain when i try to run mydomain.com/wp-admin

Please help if you have any ideas about this, any help would be greatly appreciated.

  • 2
    I have added these lines in wp-config.php and it worked. define('WP_SITEURL', 'https://domain.com'); define('WP_HOME', 'https://domain.com'); – Vignesh Chinnaiyan Jun 12 '18 at 23:48
7

I had the same problem (works fine now), here is what i done

instead of try to access to the admin panel whit yoursite.com/wp-admin i tried with yoursite.com/wp-login.php and it took me to the admin panel of my new site. Then I changed the site domain in general settings and now it works just fine.

  • Thanks, I was able to edit the settings and now the internal pages are working just fine but the home page is not working. I have updated the permalinks n the url for the home page – viCky Jan 3 at 10:38
7

My issue is resolved, i am posting this as an answer so that someone else can benefit out of it.

My issue was, siteurl and homeurl were not updated, so i have placed define('RELOCATE',true); in my wp-config.php file. And again tried to access the website , it gone to the correct url but all the css was gone. Then i headed over to wp-admin and it also came with no css but still i tried to login but this time it has taken me to the correct url and with css login page but didn't logged in. Then Again i have attempted to login and this time i have logged in successfully. Then i have changed both the urls from settings in the admin panel.

After this you must to delete all your browser cache files to delete anny kind of persistant redirection.

Hope this helps someone else dealing with the same problem.

  • That did the trick for me! – Avishai Nov 29 '18 at 23:45
  • Hi! I'm wondering whereabouts in your config file you added this, because I'm trying at several places with little success. – QuestionerNo27 Dec 10 '18 at 11:51
4

Run the following when you are changing domain:

UPDATE wp_options SET option_value = 'https://yournew.domain' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'https://yournew.domain' WHERE option_name = 'home';
  • But it's clearly not enough. The old domain will be still stored in posts, sidebars, other options and so on... – Krzysiek Dróżdż May 25 '18 at 10:30
1

Changing wp_options field will help a little, but sometimes your pages, posts and plugins will use absolute references to images and other files. In this case, you'll need to update the entire database. Since there's no easy "replace all" in phpMyAdmin (unless you construct an UPDATE statement in SQL), it's best to:

  1. Backup your entire database as an sql file. (I would include the DROP TABLE option)
  2. Export your entire database as a sql (text) file and open it in a text editor. (I use Notepad++)
  3. Do a Replace All of all instances of your old domain with your new domain. (i.e. olddomain.com with newdomain.com)
  4. Save the updated SQL and import it back into phpMyAdmin.

Voila!

  • If this doesn't fully resolve the problem: 1. Check for any references of your old domain in wp-config.php 2. Temporarily rename your .htaccess file 3. Temporarily move any security or permalink rewrite plugin folders – Tone Williams Feb 26 '17 at 16:34
  • I think this is the most comprehensive solution. Wonder why I'm the first person upvoting – che-azeh Jul 25 '18 at 15:03
0

Change the URL in option database file in phpmyadmin. Means your actual URL link. Then open wp-admin page..with wp-login.php link.. Type your authentication then in general setting change the URL directory again and access the website.

0

To just expand on Reezppo's answer,

Open PHPMyadmin in your cPanel and then click on the wp_options file and then you will see a bunch of fields that you can change and you will see the old url which you can then change manually to the new url (in two places). Then save it and go back to yoursite.com/wp-login.php and it should let you login without redirecting. Remember you will be logging in with the old Wordpress username and password (the one from the original site that you have moved).

protected by Community Jul 24 '17 at 13:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.