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

Jennifer Hinkle
Jennifer Hinkle
8,365 Points

Migrating a site

Hello,

I've been following the How to Build a Wordpress Theme and have been developing my site locally on my computer. After getting pretty far into my project, I wanted to start another and discovered that I could easily host more than one site locally. However, I stupidly named the original website root directory incorrectly. I want to migrate my site to a different folder within the same (in MAMP- I have mac) htdocs folder. However, when I followed the How to Migrate a Local Wordpress Site to a Live Server, I've gotten stuck. I successfully backed up my original site, copied those files into the new folder, edited my wp-config.php file, and created/ imported my database correctly. But when I tried navigating to localhost/newfoldername.com/wp-admin I get a 404 message saying the page can't be found. I feel as if I must have edited my wp-config file incorrectly. I changed the DB_NAME to "newdatabasename" and I think that step must be correct because localhost/newfoldername.com takes me to the site I developed. But when I add /wp-login or /wp-admin I get an error message. Also, when I click the "Home" menu option it takes me to the current live version on the web (http://newfoldername.com). I must have set the URL for the site incorrectly, defining WP_HOME and WP_SITEURL wrong. I put them as: "localhost/newfoldername.com" If this is long winded, I apologize. I'm new to development in general so my technical vocabulary is still pretty basic. (Thank you Treehouse for teaching the basics I now know!). If anyone could give me some advice or direction on what I might be doing wrong, I'd really appreciate it!

Thanks, Jenn

1 Answer

Chris McKnight
Chris McKnight
11,045 Points

You should create a vhost for the site. Open the folder /Applications/MAMP/conf/apache/extra and open the file named httpd-vhosts.conf. Add a new block at the end of the file similar to this.

<VirtualHost *:80>
    DocumentRoot "/Users/username/Sites/newfoldername.com"
    ServerName newfoldername.dev
</VirtualHost>

Also, add an entry to your hosts file. Open /etc/hosts and put a line like the following at the end.

127.0.0.1 newfoldername.dev

You will also have to replace the URLs in your local database. Find the table wp_options and replace siteurl and home with newfoldername.dev.