5

So when I go on localhost, my development environment loads fine. But when I try to go to /wp-admin, I get redirected to the production URL mysite.com/wp-admin. Where is this being set? I don't want to be redirected.

  • 1
    Do you have phpmyadmin? Search for other site URL in entire database. Probably somewhere in options. – GhostToast Jun 20 '13 at 21:20
  • Yeh I do have it. I found it in options too, one called siteurl and one called home and a few more to specific paths. Which one do I change? – Edmund Jun 20 '13 at 21:27
  • @Edmund Both. Changing just these two will suffice for basic operation on localhost, though links within posts & elsewhere will still point to production site. – TheDeadMedic Jun 21 '13 at 2:21
3

You can find and replace instances of the old URL in your database but it's best to use a tool that handles serialized data such as BackupBuddy to avoid breaking things like some plugins. Hope this helps!

1

Use find and replace to find instances of your old URL and update to your new URL.

Here is a decent article on it.

http://codex.wordpress.org/Moving_WordPress

I wrote a little script that will create the necessary SQL code to put in phpmyadmin's SQL box (please backup DB first though)

http://tools.morningstarmediagroup.com/find-replace/

Note:

You'll just want to search for the top-level domain like so: http://example.com and replace with http://new.example.com - not a good idea to involve any trailing slash.

1

You can accomplish this by using WP CLI. Just run

wp search-replace old-domain.com new domain.com 
0

Too bad WP doesnt provide in-built configs for production and local envs like PHP frameworks. You'll have to change siteurl and home in wp_options to the production site URL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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