简体   繁体   中英

Local copy of WordPress site duplicates url

I am trying to make a local copy of a WordPress site. After downloading the files I change the site url to localhost in wp_option's table, at rows siteurl and home.

在此处输入图片说明

After that the problems begins.

The path start to duplicate the url. For example, if I try to login, instead of open the localhost/wp-admin url , I get http://localhost/wp-admin/localhost/wp-login.php .

The 'localhost' part is repeating itself at url, so all my links are broking, as you can see below.

在此处输入图片说明

Also, if I try to open the homepage in localhost I keep being redirect to the original site.

I already tried to change the url altering the wp-config file and the result is the same.

What could be causing this?

METHOD-1

You need to add http:// and your project name.

在此处输入图片说明


METHOD-2

Define below code in your wp-config.php

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

METHOD-3

Put below code in your current theme functions.php

<?php
update_option('siteurl','http://localhost/digital_test');
update_option('home','http://localhost/digital_test');
?>

Important! Do not leave those lines in the functions.php file. Remove them after the site is up and running again.


NOTE: All settings should include the http:// part and should not have a slash "/" at the end.

you need to mention your default paths inside wp-config.php and theme's functions.php

wp-config.php - place at the top

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

functions.php - place at the top

update_option( 'siteurl', 'http://localhost' );
update_option( 'home', 'http://localhost' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM