本地主机上的 wordpress 链接到实时站点 [英] wordpress on localhost linked to live site

查看:32
本文介绍了本地主机上的 wordpress 链接到实时站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,我为一个朋友使用 Wordpress 搭建了一个网站,我在本地主机上开发了它并将其导出到他的实时网站 paulscreen.com

A few months ago I put together a site using Wordpress for a friend, I developed it on localhost and exported it to his live site paulscreen.com

我最近被要求为其他人做同样的事情,我以同样的方式着手,我的问题是在某个时候我访问了 paulscreen.com(我不知道如何或何时访问)并且这样做我已将他的网站设置为 viciousnature.co.uk,我假设是通过更改管理区域选项面板中的主页网址.

I have recently been asked to do the same for someone else and I set about it the same way, my problem is at some point I accessed paulscreen.com (I don't know how or when) and in doing so I have set his site to viciousnature.co.uk, I assume by changing the home url in the options panel in the admin area.

现在,当我尝试访问第一个站点的管理区域时,我被重定向到第二个站点.我一直在浏览 wordpress 代码,但只有有限的编码知识,无法找到解决问题的方法.

Now when I try to access the admin area for the first site, I get redirected to the second. I have been going through the wordpress code, but only have limited coding knowledge and cant find how to fix the mess up.

我在哪里可以找到在不使用管理区域的情况下编辑主页 url 的选项?

Where do I find the option to edit the home url, without using the admin area?

推荐答案

参见 更改站点 URL « WordPress Codex 用于不同的恢复方法.您不一定必须能够进入 WordPress 管理后端.

See Changing The Site URL « WordPress Codex for different methods to recover. You don't necessarily have to be able to get into WordPress administration backend.

最简单的快速修复是在 wp-config.php 中添加这些 define URL 指令:

The easiest quick fix is add these define URL directives in wp-config.php:

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

使用新域的 URL,这些将覆盖数据库和旧域中的 URL 设置.您对 URL 进行了硬编码,使用此方法后,您将无法再在常规设置"页面上对其进行编辑,但这会让您重新进入网站.

with the URL of the new domain, and those will override the URL settings in the database and the old domain. You're hardcoding the URLs and you won't be able to edit them on the General settings page anymore after using this method, but that will get you back into the site.

如果在将站点和数据库移动到新域时需要更改域,则需要使用 phpmyadmin 中的查询来更改数据库中的所有 URL,即那些站点 URL,以及帖子内容中的主题选项等

If you need to change domains when moving a site and database to a new domain, you need to use queries in phpmyadmin to change all URLs in the database, i.e. those site URLs, as well as in theme options, in post content, etc.

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

UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com/','http://www.newdomain.com/');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com/', 'http://www.newdomain.com/');

UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/');

2017 年 2 月 20 日的重要更新:

将站点和数据库移动到新的 URL 或域时,现在最好使用它 - interconnectit.com WordPress 序列化 PHP 搜索替换工具 - 而不是我在上面发布的直接在 PHPMyAdmin 中查询.Interconnectit 工具将正确处理数据库中的序列化数据,例如 Wordpress 主题和插件使用的数据;在 PHPMyAdmin 中使用这些查询会破坏这些数据,例如用于主题选项、小部件设置等,之后您必须重置所有这些选项,这可能会很混乱.

When moving a site and a database to a new URL or domain, it's now best to use this - interconnectit.com WordPress Serialized PHP Search Replace Tool - rather than queries directly in PHPMyAdmin that I posted above. The Interconnectit tool will correctly handle serialized data in the database, such as used by Wordpress themes and plugins; using those queries in PHPMyAdmin will break such data, such as used for theme options, widget settings, etc, and you will have to reset all those options afterward, which can be a mess.

这篇关于本地主机上的 wordpress 链接到实时站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆