Local host show live url

Issue Summary

The local website in my host when I press open site it opens the real website. Even when I write the local url.

Replication

Hi, I made a copy from a website. Use cpanel and download the files and database and then in local create a new site and upload the files. it works but when I press “opensite” or write the local URL automatically changes to the real URL and opens the website. Sorry I am new to local so is this ok or when I do changes now in the local version I am doing them in the real website?

Hey @ricardo_creates – Welcome to the Local Community Forums!

When you imported the site from cPanel, how was it imported into Local?

Usually, the easiest way to download a site from cPanel to Local is to create a backup on the remote site using something like BackWPup

This will give you a zip file that you can download and import by dragging and dropping the Zip onto Local.

If you didn’t import that way, and did something a little more manual (which is what it sounds like) then you’ll likely need to still import the DB as well as do a search for the remote domain a replace it with the local domain.

The last thing that comes to mind as possibly being an issue is that maybe there’s a caching plugin in place? You’ll likely want to disable any caching plugins in the Local environment so that you’re getting an accurate look at what the site is.

Hi Ben, thanks for the help.
Basically my steps were:
Compress public_html in file manager and dowload them
Went to phpMyAdmin and export in SQL format
Create website in Local
Went to local folder, delete all and paste the files that I had compressed.
Went to adminer, dump the database and import the one that I had export previsously
Replace live site urls with local urls:

 UPDATE wp_options SET option_value = replace(option_value, 'https://www.yoursitename.com', ' 
 http://yoursitename.local') WHERE option_name = 'home' OR option_name = 'siteurl';
 UPDATE wp_posts SET post_content = replace(post_content, 'https://www.yoursitename.com', 
  'http://yoursitename.local');
  UPDATE wp_postmeta SET meta_value = 
  replace(meta_value,'https://www.yoursitename.com','http://yoursitename.local');

Update site details

define('DB_NAME', 'local');
define('DB_USER', 'root);
define('DB_PASSWORD', 'root');
define('DB_HOST', 'localhost');

Then give an error about wordfence-waf. that is now fixed.
Then went to local and launch site and that was it.
What you think?

Yeah, that’s one way of doing it.

I think an easier way would be to download those files and the DB dump and then compress them into one zip file.

From there, you can drag and drop the zip onto Local to import it. That would handle the importing of the DB as well as the search-and-replace for the site domain.

Something like the steps outlined in the “Restoring From Only Local Site files” section of this help doc:

I am compressing now to try but I made it work before. Kinda of.
I think was caching problem so I clean the cache on chrome and went to the local site instead.
But this shows when it goes to site:

in the header file in ine 11 it’s this:

if(session_id() == '') {
	session_start();
}

Sorry I’m just to confused with all this. Any idea what that might come ? I search in google and I found that might be some php update but not sure…

Yeah, this looks to be related to how the theme is built.

That warning is letting you know that the theme can’t read session data, but the path that is referenced is for the remote filesystem, which isn’t something that you have within this Local site.

My guess is that when pulling down the site, there’s a number of custom settings related to the remote environment. Instead of pulling down the whole site, you might try just downloading the wp-content folder and then compressing that folder with the database dump.

From there, import the zip file by dropping it onto Local. Doing it this way will ensure that you’re only pulling down the plugins, themes, media needed for the site, and not the other custom environment settings.

Yeah I give that a go.
The thing is that the website has 47 plugins active, had 2 previous developers that mess with the website and the owner is not sure what they did or not. It’s hosted on shared host so for example I tried to use Duplicator or other plugin and just breaks in the middle.
I am running out of options. Now I have it on Local “just” has that error on top but the rest is there.
I will do this and tell you tomorrow if it worked better or not.
Thank you Ben

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.