DopeAt DopeAt - 1 month ago 12
PHP Question

Wordpress local admin redirects to live server admin page

Just transfer my live server wordpress website. Everything wprks fine when i realize that the locally localhost/site/wp-admin is redirecting in the live one.

And i can't access locally website.

What should i do to fix this, and work locally to do some experiments?

Thats the sql commands i put after transferring database locally

UPDATE wp_options SET option_value = replace(option_value,'http://www.olddomain.com/', 'http://www.newdomain.com/') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com/','http://www.newdomain.com/');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com/', 'http://www.newdomain.com/');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/');

Answer Source

I use the following in wp-config.php to fix this:

define('DOMAIN_ROOT', 'http://localhost/site');
define('WP_HOME', DOMAIN_ROOT);
define('WP_SITEURL', DOMAIN_ROOT);