admin管理员组

文章数量:1291283

So basically whats in the title. I migrated the company website to my localhost to implement some changes. First I cloned the repository, then I created the database, and uploaded the sql file. Configured the wp-config.php file. Ran the sql querries to update the links in the databse, restarted everything, and when I go to the local host address it throws an "oops, page not found" error. What's weirder is that the wp-admin page works perfectly and I can see all the contents of the site in there, but whenever I try to open any page it throws the same "page not found" screen. The links seem to be working well too. And I even added this:

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

To the wp-config.php file. I'm at loss here, because I did everything I usually do to migrate a site but couldn't get it to work. I searched here for an answer but most, if not all of them suggest the same fixes of:

"Update the urls in the sql" (done) "Make the .htaccess writable and go to the permalinks page on wp-admin and save changes" (done) "Update WordPress to the latest version" (I'm not allowed to make such decisions, especially because the site in live runs on an older WordPress, 5.4.1, and it works fine)

For the record, these are the sql querries I ran:

UPDATE wp_options SET option_value = replace(option_value, '', 'http://localhost/example') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = REPLACE (guid, '', 'http://localhost/example');

UPDATE wp_posts SET post_content = REPLACE (post_content, '', 'http://localhost/mysite/');

UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, '', 'http://localhost/example/');

UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="', 'src="http://localhost/example/');

UPDATE `wp_posts` SET `guid` =  REPLACE( `guid` , '' , 'http://localhost/example/' ) WHERE `post_type` = 'attachment';

UPDATE wp_posts SET  guid = REPLACE (guid, '', 'http://localhost/example/') WHERE post_type = 'attachment';

Where "example" is the site im working on, but I cant share due to company policies. Any help would be greatly appreciated.

So basically whats in the title. I migrated the company website to my localhost to implement some changes. First I cloned the repository, then I created the database, and uploaded the sql file. Configured the wp-config.php file. Ran the sql querries to update the links in the databse, restarted everything, and when I go to the local host address it throws an "oops, page not found" error. What's weirder is that the wp-admin page works perfectly and I can see all the contents of the site in there, but whenever I try to open any page it throws the same "page not found" screen. The links seem to be working well too. And I even added this:

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

To the wp-config.php file. I'm at loss here, because I did everything I usually do to migrate a site but couldn't get it to work. I searched here for an answer but most, if not all of them suggest the same fixes of:

"Update the urls in the sql" (done) "Make the .htaccess writable and go to the permalinks page on wp-admin and save changes" (done) "Update WordPress to the latest version" (I'm not allowed to make such decisions, especially because the site in live runs on an older WordPress, 5.4.1, and it works fine)

For the record, these are the sql querries I ran:

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

UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.example', 'http://localhost/example');

UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.example', 'http://localhost/mysite/');

UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.example', 'http://localhost/example/');

UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://www.example', 'src="http://localhost/example/');

UPDATE `wp_posts` SET `guid` =  REPLACE( `guid` , 'http://www.example' , 'http://localhost/example/' ) WHERE `post_type` = 'attachment';

UPDATE wp_posts SET  guid = REPLACE (guid, 'http://www.example', 'http://localhost/example/') WHERE post_type = 'attachment';

Where "example" is the site im working on, but I cant share due to company policies. Any help would be greatly appreciated.

Share Improve this question edited Jun 9, 2021 at 23:22 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Jun 9, 2021 at 20:06 Alejandro Arturo PumpidoAlejandro Arturo Pumpido 13 bronze badges 4
  • Remove trailing slashes in those two defines. – Frank P. Walentynowicz Commented Jun 9, 2021 at 20:59
  • I already tried that and its the same result... – Alejandro Arturo Pumpido Commented Jun 9, 2021 at 21:06
  • Did you try deactivating all plugins, and reverting to starter theme, just to check? Also, I have had problems like this before, where I had to delete .htaccess, and THEN save permalinks - it's worth a shot. – WPTricksDK Commented Jun 9, 2021 at 21:09
  • Using SQL to update URLs is really tricky, especially when some data may be stored in serialized formats. You might want to try starting from scratch and using WP CLI's wp search-replace function which takes into account more complex replacements, particularly with the --precise parameter. – phatskat Commented Jun 10, 2021 at 14:33
Add a comment  | 

1 Answer 1

Reset to default 0

So I found the answer by myself. It was rather simple. The localhost server I was running uses PHP 8.0, while the website I was trying to migrate runs on WordPress 5.4.1 using PHP 7.3. All I had to do was to configure xampp to run PHP 7.3 on that particular project and done. The site showed up without any issue.

So I'm debating between deleting the question or leaving it up, because it was a dumb problem, but also it's a pretty good educative tool of why you should always check that your localhost server uses the same versions of the live server.

本文标签: