WordPress migration from production to local environment redirecting incorrectly

I successfully transferred my WordPress website from the production server to my local development environment. Here’s what I did:

  1. Downloaded all website files from the live server
  2. Set up the files on my local machine
  3. Exported and imported the database to localhost
  4. Updated all URLs in the database using SQL commands

I used these database queries to change the URLs:

UPDATE wp_options SET option_value = replace(option_value, 'https://livesite.com/','http://localhost/mysite/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'https://livesite.com/','http://localhost/mysite/');
UPDATE wp_posts SET post_content = replace(post_content,'https://livesite.com/','http://localhost/mysite/');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://livesite.com/','http://localhost/mysite/');

The homepage loads perfectly fine, but I’m having problems with navigation. When I click any menu items or try to access the WordPress admin area, everything redirects to the XAMPP control panel instead of staying within my local WordPress site. What could be causing these redirect issues and how can I fix them?

sounds like a xampp config prob. check your apache virtual hosts - its probably defaulting to the xampp dashboard instead of ur wordpress folder. also clear ur browser cache completly. old redirects can get stuck and cause this exact issue.

Your redirect issue is likely due to common configuration problems. Examine your .htaccess file in the WordPress root; ensure there are no references to your live site and check for rules that misdirect traffic, especially those concerning RewriteBase. Also, review wp-config.php for any hardcoded WP_HOME or WP_SITEURL constants that may conflict with your database updates. If you can access the admin area, navigate to Settings > Permalinks and resave your permalink structure; this often resolves many redirect issues encountered after migrations. In my experience, these adjustments typically rectify the problem.

Your SQL updates only hit the main WordPress tables but missed some key spots. WordPress stores URLs all over the place - not just where you looked. Check wp_comments for comment URLs, and definitely check wp_options and wp_postmeta tables for serialized data. Here’s the thing with serialized data: when WordPress packs arrays and objects, it includes character counts. Regular find-and-replace breaks this because it messes up those counts. You’ll need WP-CLI or the Better Search Replace plugin to handle serialized stuff properly. Also double-check your local server setup - make sure your document root points to the WordPress folder, not just the XAMPP htdocs root.