admin管理员组

文章数量:1122832

I have migrated more than 50 websites from Live server to Localhost in my career but have not faced this issue till now. I used ALL IN ONE WP MIGRATION to export the data from live server. I replaced the url during export process.

/ to http://localhost/example/

I imported the data in my fresh wordpress installation in my localhost. Every thing went fine. My home page loads fine as well. But when I click the home page logo which should redirect to http://localhost/example/ but redirects to http://localhost/dashboard of XAMPP. When I click the menu item -> Services which should redirect to http://localhost/example/services but redirects to http://localhost/services.

I tried changing the Site Address Url and Wordpress Address Url to http://localhost/example/.

My .htaccess file.

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]
</IfModule>

# END WordPress

Any help is appreciated.

I have migrated more than 50 websites from Live server to Localhost in my career but have not faced this issue till now. I used ALL IN ONE WP MIGRATION to export the data from live server. I replaced the url during export process.

http://www.example.com/ to http://localhost/example/

I imported the data in my fresh wordpress installation in my localhost. Every thing went fine. My home page loads fine as well. But when I click the home page logo which should redirect to http://localhost/example/ but redirects to http://localhost/dashboard of XAMPP. When I click the menu item -> Services which should redirect to http://localhost/example/services but redirects to http://localhost/services.

I tried changing the Site Address Url and Wordpress Address Url to http://localhost/example/.

My .htaccess file.

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]
</IfModule>

# END WordPress

Any help is appreciated.

Share Improve this question asked Jan 20, 2021 at 19:09 Sujan ShresthaSujan Shrestha 31 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

go to PHPMyAdmin and click your database then check wp_options -> siteurl, it should be http://localhost/example/

PHPMyAdmin -> open_database -> wp_options -> siteurl

You can do this by running an SQL query in phpMyAdmin. Make sure you have selected your local site’s database and then click on SQL.

In phpMyAdmin’s SQL screen copy and paste this code, make sure that you replace example.com with your live site’s URL and http://localhost/example' with the local server URL of your site.

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

This query will replace refences to your live site’s URL from database and replace it with the localhost URL.

本文标签: migrationIssue In Links after migrating from Live server to Localhost XAMPP