WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to WordPress. A friend asked me to redesign his WP blog and I've installed it on my Mac using MAMP. I went through the database setup and imported the site's existing DB and added the tables. It all looks good, as far as I can tell, on the phpMyAdmin site.

When I go to url "localhost" in Chrome (and other browsers) I see the blog's front page, which is definitely local, but if I try to login, I'm sent back online. This also happens if I click on any of the links in the blog.

I've check that wp-config.php DB_NAME matches the name of the DB I downloaded. Anyone got any ideas what's going on?

Thanks Gavin

share|improve this question

Try adding this to your wp-config.php file:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME',    'http://' . $_SERVER['HTTP_HOST']);

That will define your site URL as whatever happens to be in the browser location bar. Very useful for moving a site from server to server without actually changing the siteurl and home location in the database. Just don't leave this on a production site.


share|improve this answer
Worked a treat. Thank you so much – Gavin Aug 7 '12 at 13:51
Awesome, glad to hear it! It would be great if you could mark this as the accepted answer so others can find it as well. – Dalton Aug 7 '12 at 14:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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