Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Nicholas Nelson
Nicholas Nelson
24,526 Points

WP Migration Problem - Cannot login to newURL admin

I am following along with the How to Migrate a Local WordPress Site to Live Server video. When we get to about 08:30 Zac logs in to wptreehouse.com/portfolio-project/wp-admin. When I enter MyExampleURL.com/dev-directory/wp-admin into the broswer, the browser takes me to localhost/.../wp-admin. That is to say that it takes me to the old URL. Are others having this experience?

Through some searching I have seen advice to edit the site url in the db.sql from the old to new. In my case there are 400 cases of "localhost" in my db.sql some in comments from the wordpress backup. Does one replace all of them? Others have mentioned a(n) .htaccess file?

Additionally, when first browsing to MyExampleURL.com/dev-directory I get the index.php not the page I set as the front page. I thought it might have to do with resetting links I tried to follow further with the video when I found I couldn't go any further without the proper admin page :(

4 Answers

Hi Nicholas,

Open your themes functions.php file , just after <?php add the following code below replacing example.com with your URL.

update_option('siteurl','http://example.com'); update_option('home','http://example.com');

save the file and refresh the site homepage and all should be fine , don't forget to remove the update_options from the functions.php file.

Cheers, Neil

Nicholas Nelson
Nicholas Nelson
24,526 Points

Resolved?

Ok I just went ahead and opened my database sql file in my text editor and did a search and replace all swapping the old url for the new one.

My front page worked, and I'm able to access wp-admin at the new url. At that point I just saved the permalink setting like on the video.

At first glance things seems to work.

Nicholas Nelson
Nicholas Nelson
24,526 Points

New found issue,

One of my custom field groups installed missing fields. I don't know that this is a problem that is related to the last.

Strange. And stranger yet is that the rest of my custom fields are fine.

Hi! Try adding define('RELOCATE',true); just before the comment line that says "That's all, stop editing!" After that login to your admin panel from yourdomain.com/wp-login.php, then eliminate define('RELOCATE',true); from your wp-config.php

Nicholas Nelson
Nicholas Nelson
24,526 Points

Hey Marcos, I tried this when having the same problem moving from subdirectory to root. I guess it did not work for me. Still can't log in to my admin page.

Nicholas Nelson
Nicholas Nelson
24,526 Points

Thanks folks. Fortunately or unfortunately, the find and replace seemed to work. Spent a couple min on my custom field group and it seems to work. Next time (I'm sure there will be a next time), I'll have to try these!

Nicholas Nelson
Nicholas Nelson
24,526 Points

I went through this again when moving the site from a subdirectory to the root of a server. I saw the same problem. I then went in to my .sql database file and changed the 'siteurl' and 'home' to 'http://example.com' . Then I was able to login to wp-admin. I then followed suit with the search and replace plugin. I still had the same problem with the custom field getting a little screwy. Luckily it didn't take too long to re-enter the information, however if you had a more complex field and more entries it would be a major setback. I haven't gotten a lead as to why/how that happened.