14

I have download the code and export the database from server and setup the site on my localhost also I have been changed the home and site URL in wp_options table I am able to login at wp-admin but when I am clicking on the home page it redirect me to live site.

If anyone know the issue please help me.

Thanks in Advance.

4
  • Did you check your menu links or if the links are hard coded? Apr 18 '17 at 6:49
  • Yes I have checked its not static Apr 18 '17 at 6:53
  • 1
    Check htaccess for any redirect rules to live site Apr 18 '17 at 7:17
  • there was no .htacces I have put the htaccess but not working Apr 18 '17 at 7:18
10

Try following

  • If there are caching plugins installed like W3 total cache. Then purge cache first. Or may be disable them for time being

  • Perform Search and Replace in the database for Old Site URL. You can Use this Plugin

  • Reset Permalinks ( Dashboard >> Settings >> Permalinks )

  • Last but not the least. Clear your browser Cache and History

6
  • 1
    I have already done this and this works for me. Thanks Apr 18 '17 at 7:35
  • 1
    The Last option works for me :) Feb 4 '18 at 21:33
  • Last worked for me too - still don't get why that would happen!? :(
    – Julix
    Jun 21 '18 at 18:04
  • 1
    Glad it helped you. :) Jun 23 '18 at 11:17
  • I have tested and confirmed: in my case it was the browser's cache. I had done all previous steps to no avail and then moved to another browser to check. Done. It was cache.
    – marquito
    Jan 14 '19 at 21:29
14

According to the wordpress reference here

Add these two lines to your wp-config.php, where "example.com" is the correct location of your site.

define('WP_HOME','http://example.com'); 
define('WP_SITEURL','http://example.com');

OR

Edit functions.php

Add these two lines to the file, immediately after the initial "

update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );

Or check the .htaccess file as well if added any rewrite rule for redirect the website.

Hope this help!!

4
  • So, it's working or not? Apr 18 '17 at 7:15
  • not working but when I changed the permalink structure and then change back it to old one its working. Apr 18 '17 at 7:17
  • Great dude you have solved!!! Apr 18 '17 at 7:20
  • worked for me, but i also had to disable browser cache and add all of these together: define('WP_HOME','http://localhost'); define('WP_SITEURL','http://localhost'); define('WP_CACHE', false); define('WP_DEBUG', true);
    – oriadam
    Feb 1 '21 at 21:38
1

Had to change these lines in my wp-config.php from

define('WP_CACHE', true);
define( 'WPCACHEHOME', 'C:\wamp64\www\wp-content\plugins\wp-super-cache/' );

to

define('WP_CACHE', false);
//define( 'WPCACHEHOME', 'C:\wamp64\www\wp-content\plugins\wp-super-cache/' );
1
  • 1
    worked for me only after adding all of these and disabling browser cache: define('WP_HOME','http://localhost'); define('WP_SITEURL','http://localhost'); define('WP_CACHE', false); define('WP_DEBUG', true);
    – oriadam
    Feb 1 '21 at 21:37
0

you can change live url to local url directly in database table wp_options two option_name field

1) siteurl
2) home

After this save permalink.

Hope is useful

1
  • I have changed it already Apr 18 '17 at 7:14
0

You can also solve this problem by installing WP cli and running :

wp search-replace 'example.com' 'example.local'

Check the codex for more info. But as JItendra said, it's important to clear the browser cache too after doing this.

0

Try remove any redirecting plugins if you have in your live site codebase. I solved the same issue by removing the "safe-redirect-manager" plugin in local.

-2

I just change my permalink structure to plain and again to old one then Its working. thanks all of you for your help. :)

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.