I downloaded a website from live to local. I want to run it. But when I open it on localhost, it redirects me to live url. I have made changed to DATABASE wp_options
table and replaced live URL with my local url. But still it is not working. Please guide me.
3 Answers
If you've updated the options in the dtabase and are still getting redirected.
You can also define both the WP_SITEURL
and WP_HOME
in your test wp-config.php
define( 'WP_SITEURL', 'http://example.com.mytestdomain.com' );
define( 'WP_HOME', 'http://example.com.mytestdomain.com' );
1) Make sure the wp-config.php doesn't have multisite reference settings such as define("DOMAIN_CURRENT_SITE", "somesite.com" );
. If it does, delete these settings
2) If you have updated siteurl
and home
settings in the *_options
table to use local settings and it still doesn't work, then
3) Delete all themes but a basic one (twentytwelve, twentythirteen,...) and delete all plugins. In this way, you are running the Wordpress core functionality.
4) If that still doesn't work, clear the cache of your browser or try a different potent browser.
5) If all this doesn't work, you may be faced with a network configuration issue and I think it goes beyond the scope of this question ?
If you are on windows you can change your hosts file to point the url to the local host ip. A similar process on Mac. Either way you won't have to change the db as you will be changing your local hosts file to point that url back to the host machine. It's actually more convenient because there is no need to change the website at all.
(On mobile right now otherwise i would add detailed instructions on this add i keep a reference file at home for myself)
NOTE: some plugins may be affected by this. Notably (and not actually a plugin) is the search and replace tool from interconnectit.com.
UPDATE: (adding excerpt from my own notes)
Windows
1) add this line to the Windows Hosts file C:\WINDOWS\system32\drivers\etc\hosts
#BEGIN CUSTOM
127.0.0.1 yourwebsite.com
#END CUSTOM
MAC
1) add this line to the Apple Hosts file /private/etc/ (I use terminal command nano /etc/hosts)
#BEGIN CUSTOM
127.0.0.1 yourwebsite.com
#END CUSTOM
.htaccess
file?