Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Installation complete, merging of WP to self hosted site complete, but will not let me login as .com/wp-admin/? Why?

I successfully installed & merged Wordpress last night and went to login this morning to the "websitename.com/wp-admin/" and it rerouted me to "websitename.wordpress.com/wp-admin", so I logged into that to see what's going on, and I don't really have access to the self hosted one because when I click on it, a screen pops up about how it's not safe, etc. I don't know what to do, but I want to start working on the self hosted one. Is it because the wordpress hosted one is still active that it's not working properly?

If you were on a Wordpress.com blog previously, then it might be redirecting your domain to that previous blog still. Make sure you deleted the redirect on your previous site. And if that doesn't seem to work, clear your browser cache or try it in a different browser. I had the same thing happen to me. Hopefully that will do the trick!

1 Answer

Chris Shaw
Chris Shaw
26,662 Points

Hi Micaela,

The reason this is happening is because WordPress stores your website address statically within the database so that images, theme paths etc. link correctly, to fix this you will need to download the search and replace tool linked below which deserializes the database objects and updates strings based on the input you give it.

https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Before using this tool I would recommend you make a backup of your current database, once you have that do the following.

  1. Download the Search and Replace script.

  2. Upload the Search-Replace-DB-master folder to the root folder (the same folder wp-config.php lives in) on your server.

  3. Visit websitename.com/Search-Replace-DB-master in your browser.

  4. In the replace field use the domain for your WordPress.com hosted site: websitename.wordpress.com.

  5. In the with field use your self hosted domain: websitename.com.

  6. Hit the Live Run button and in the results panel you should see a lot of changes occurring.

  7. Visit websitename.com/wp-admin again and this time you shouldn't be redirected.

Let me know if any of that is confusing or if you have issues.

PLEASE NOTE: Once you're done with this script you SHOULD remove it from your server as it does pull in your database authentication details automatically.

Hey Chris! Thank you heaps for the advice. I've got a few questions.

How would I backup my current database?

Where do I upload the Search-Replace-DB-master folder? Through Cpanel or filezilla?

And where would I remove it once I finish uploading? Through Cpanel as well?

I'm a big time newb.

Thanks so much.

Chris Shaw
Chris Shaw
26,662 Points

How would I backup my current database?

In cPanel on the main page under the databases section there is phpMyAdmin, open that and on the left hand side of the page will be a list of databases, select the one associated with your WordPress installation and follow the instructions as per the following link.

http://codex.wordpress.org/Backing_Up_Your_Database#Backup_Process_with_phpMyAdmin

Where do I upload the Search-Replace-DB-master folder? Through Cpanel or filezilla?

You can use either cPanel's file manager or FileZilla, they both do the same thing with the exception that FileZilla uses FTP protocols while cPanel's file manager uses HTML5 technologies

And where would I remove it once I finish uploading? Through Cpanel as well?

Again you can use either.

I'm trying to upload the Search Replace folder to cpanel, but it wont upload the whole folder. There are about 6 items in it, do I have to upload each little piece manually?

Can I just delete the previous account I had that's now websitename.wordpress.com ?

I've always owned the domain name.

Chris Shaw
Chris Shaw
26,662 Points

If you use FilaZilla you can upload the entire folder in one hit, within cPanel you can upload the ZIP file and then extract it via file manager by right clicking on the file and hitting extract.

When you say upload the Search Replace file to the same folder as wp-config, are you talking about the public_html foldeR?? I did that and step 3, which was 'Visit websitename.com/Search-Replace-DB-master in your browser.' didn't work, it said 'page not found' but it was still under the context of my website

Chris Shaw
Chris Shaw
26,662 Points

When you say upload the Search Replace file to the same folder as wp-config, are you talking about the public_html foldeR??

Yep.

I did that and step 3, which was 'Visit websitename.com/Search-Replace-DB-master in your browser.' didn't work, it said 'page not found' but it was still under the context of my website

It sounds like either

  • the folder isn't called Search-Replace-DB-master
  • or Search-Replace-DB-master is nested within another folder within your public_html directory

:(

I did all of that, the folder name is right and in the correct spot and it's still not working :( Is there any other route I can take to fix this ?

It's so bizarre.

Chris Shaw
Chris Shaw
26,662 Points

Without been able to see your file manager it's hard to say what the issue at hand is, if you could please take a screenshot of your file manager, one of your public_html and one of the Search-Replace-DB-master folder contents.

Chris Shaw
Chris Shaw
26,662 Points

Everything looks fine in your screenshots, I did however visit your site and http://xxxxxxxx.com/Search-Replace-DB-master/ worked for me, I've blanked out your domain on purpose but for me the page came up as expected.

Weird, I just tried it again, and it worked for me too. So you're sure that once I do this I won't have any more problems with wordpress toggling back and forth between xxxxxx.wordpress.com and xxxxxx.com? I think/hope I backed up my database correctly.. Do I mark the regrex box in Search Replace DB master?

Chris Shaw
Chris Shaw
26,662 Points

So you're sure that once I do this I won't have any more problems with wordpress toggling back and forth between xxxxxx.wordpress.com and xxxxxx.com?

Yes, I use this tool every time I make backups of production databases for use locally.

Do I mark the regrex box in Search Replace DB master?

No, you only need that box for specific string matches, switching the site url is a simple find and replace.

Okay, quick question before I do the Search Replace DB thing, you don't think that the reason it's toggling is because I'm visiting a different country? (probably a silly question but I don't know if that messes with the server or anything) I'm just worried that I'll mess everything up and do not want to do that.

I SO APRECIATE YOUR HELP!

Chris Shaw
Chris Shaw
26,662 Points

Okay, quick question before I do the Search Replace DB thing, you don't think that the reason it's toggling is because I'm visiting a different country?

No, as I said earlier the redirect occurs because the old URL is still in the database, when WordPress detects you're not logged in it uses your site URL to switch to the login page.

I'm just worried that I'll mess everything up and do not want to do that.

The worst that can happen is the URL has a typo in which you can fix that by running the tool again but instead you would search for the typoed string instead the old URL, in all the times I've run this tool I've never had it fail or mess things up.

Okay, so I just did the whole 'Search Replace DB' process on chrome, and then went back and deleted the folder through cpanel, and it the website didn't toggle....but then I tried it in Safari, and it still pulled up the wordpress.com site, so I did the 'Search Replace DB' process on Safari and it didn't toggle anymore.. Would that make sense that I had to do that? Or is that odd?

Now it's gone back to toggling between xxxxxx.wordpress.com and xxxxxx.com (oh no!), why would it do that after I did the search replace db thing, and for both browsers?

I'm very desperate, and have been working on fixing this for probably 10 hours total :(. Is there any way I can give you my wordpress info so you can log in and have a look?

Chris Shaw
Chris Shaw
26,662 Points

Hi Micaela,

I just tried your URL and it now shows the correct redirect URL for me, things you can try.

  1. Clear your cache
  2. Try a different browser

Apart from that I can see that the search and replace tool has done it's job.

Hey Chris!

I've actually never had a problem with being redirected if you go to mywebsitename.wordpress.com . I've owned the domain for awhile. The problem is that for some reason when I go to mywebsitename.com/wp-admin (to edit my site using self hosting capabilities) I am being redirecting to login to mywebsitename.wordpress.com and it's requiring the u/n and p/w I had before I began to process to self host. So when I try to put in my new u/n and p/w (that I created when I installed WP in the self hosting process) it doesn't work and says it's unrecognizable or the account has been deleted or something like that. So anytime I try logging into my website through myurl.com/wp-admin I am being redirected to log in to myurl.wordpress.com . It's like it's picking up on two different websites with the same URL, but I've never even used the xxxxx.wordpress.com URL because like I've owned the domain for awhile. I hope what I'm saying makes sense. It's just frustrating because I want it to be fluid and consistent, where I'm able to simply login to myurl.com/wp-admin and edit my site that way, I don't want to have anything to do with xxxx.wordpress.com . How can this be fixed?