Development WordPress admin link redirecting to li

2019-07-03 08:11发布

I'm trying to make new changes to a WordPress site I have. So I copied all files and exported to new development sub-domain. Made new database for the sub-domain and imported the database from live site.

Live site: http://mysite.com

Dev site: http://dev.mysite.com

Seems to be working, but all nav links still point to live site. And main issue is when I go to http://dev.mysite.com/wp-admin, I get redirected to live site. This is link I'm getting redirected to:

http://mysite.com/wp-login.php?redirect_to=http%3A%2F%2Fdev.mysite.com%2Fwp-admin%2F&reauth=1

Any ideas?

Thanks

4条回答
beautiful°
2楼-- · 2019-07-03 08:53

Look in your Wordpress database for the wp_options table.

In the option_name column, find the "siteurl" row. Change the option_value in that row to http://dev.mysite.com .

Look again in the option_name column for the row with "home" in it. Change the option_value in that row to http://dev.mysite.com .

That should do it.

查看更多
可以哭但决不认输i
3楼-- · 2019-07-03 08:56

The answers above are correct, most of the time editing the 'home' and 'site' url in the wp_options table will do the trick, however sometimes it's necessary to run a search and replace on the database (use at your own risk):

https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

This has worked very well for me in the past.

Also, updating your permalink settings by going to Settings->Permalinks and just clicking 'Save' will often fix url problems.

EDIT

Alternatively, since you do not have access to wp-admin for updating permalinks, you can try this:

Edit wp-config.php and add this:

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

where http://example.com is your site url.

Directly after "That's all, stop editing!" insert this line:

define('RELOCATE',true);

Then, navigate to http://example.com/wp-login.php

Please let me know if that works or not.

查看更多
叼着烟拽天下
4楼-- · 2019-07-03 08:56

Wp-login was missing from the dev site. For some reason, it didn't copy over. So it caused the 404 when trying to access wp-admin.

查看更多
时光不老,我们不散
5楼-- · 2019-07-03 08:59

in your wp_options table, edit the first few records (sorted asc by ID) and edit them to have the correct URL.

You can also identify other options by using a SQL similar to SELECT * FROM wp_options WHERE option_value like '%mysite.com%'

查看更多
登录 后发表回答