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

Various troubles with live to local development - underlying issue in my approach?

Hello,

I am having some more complex issues with XAMPP and MAMP that I cannot find the answers to on the forums.

I am running MAMP on my iMac and XAMPP on my windows laptop.

On both systems, I have chosen to leave the root folder as the htdocs folder. I have downloaded, via FTP, all the contents of the public_html folder of the live site and have exported the SQL databases and subsequently imported them into my local system's PHPMyAdmin.

On my iMac, localhost shows the link to the website but upon clicking on it, only part of the website is loaded: The general layout is loaded, but a lot of the content is not loaded and some of the designs (such as icons) are simply boxes representing the space where the designs should be. Moreover, in the body of the page where the writing and photos should be displayed is a 404 error.

The error I am experiencing on my windows is simply that upon accessing localhost, I click on the website and a 404 error occurs.

I have the feeling that I am missing something in the workflow of wordpress manual backups. It's hard to ask the right question when I don't know what it is that I don't know! Nevertheless, I have continuously run into problems whenever attempting to backup live sites and work with the local version of them. Similarly, this can lead to errors when migrating the local version live again (more specifically, when migrating the local version to the live staging site for testing purposes).

Please advise.

I'm not sure where to go on a mac, but I had this same issue a long time ago when trying to use WAMP on my PC. Based on what you've described, it sounds like it could be any of the following:

1) Most likely it has to do with the links that are assigned on your website. localhost is still technically http://localhost/yourwebsitename. So make sure your site follows that convention, including the image paths. If you are using a database for something like WordPress, you can run the SQL command to search replace links:

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');

2) The hosts file in Windows can affect where your localhost resolves to. Usually XAMPP or WAMP will ammend this as needed, but you may need to have a look just in case. Make sure that you have full administrative rights here: \Windows\System32\drivers\etc\hosts

It should look something like this:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1   localhost
::1 localhost

Hopefully one of those helps. Best of luck!