url wordpress_如何更改您的WordPress网站URL(逐步)

url wordpress

Do you need to change your WordPress URL? Whether you’re moving from HTTP to HTTPs, changing your domain name, migrating from local server to live site, or transferring to a subdomain, you will need to know how to change your WordPress site URL.

您需要更改WordPress URL吗? 无论您是从HTTP迁移到HTTP,是更改域名,从本地服务器迁移到活动站点,还是转移到子域,您都需要知道如何更改WordPress网站URL。

The WordPress address and site address are extremely important fields because they reference the address of your website on the internet and the location of your website files.

WordPress地址和站点地址是非常重要的字段,因为它们引用您的网站在Internet上的地址以及您的网站文件的位置。

In this article, we will share four different ways to easily change your WordPress site URLs (step by step). This guide will specially come in handy when you are fixing common WordPress errors or moving a WordPress site.

在本文中,我们将分享四种不同的方法来轻松更改WordPress网站URL(逐步)。 当您修复常见的WordPress错误移动WordPress网站时,本指南特别有用。

Easily change your WordPress site URLs
为什么要更改WordPress网站URL? (Why Change WordPress Site URLs?)

There are many reasons why you might need or want to change your WordPress URL. For example:

您可能需要或想要更改WordPress URL的原因有很多。 例如:

Apart from that, you may need to change the WordPress address settings if you are seeing too many redirects error in WordPress or when troubleshooting another WordPress error.

除此之外,如果您在WordPress中看到太多重定向错误或在对另一个WordPress错误进行故障排除时,可能需要更改WordPress地址设置。

WordPress地址与站点地址 (WordPress Address vs Site Address)

When changing WordPress site URL, you will need to update two separate settings: WordPress Address and Site Address.

更改WordPress网站URL时,您将需要更新两个单独的设置:WordPress地址和站点地址。

This can be confusing for many beginners because they don’t know what’s the difference between the two settings.

这对于许多初学者可能会造成混淆,因为他们不知道这两种设置之间的区别。

Your WordPress Address (URL) is the address where WordPress files and folders are stored including your admin pages, media files, plugins, themes, etc.

WordPress地址(URL)是WordPress文件和文件夹的存储地址,包括您的管理页面,媒体文件,插件,主题等。

Your Site Address (URL) in WordPress is the public facing part of your website. This is what your visitors will type in to reach your website. This is also the link that you put on your business cards.

WordPress中的您的站点地址(URL)是您网站的面向公众的部分。 这是您的访问者将输入的内容,以访问您的网站。 这也是您放在名片上的链接。

For majority of users, the WordPress Address and Site Address URL will be the exact same link.

对于大多数用户,WordPress地址和站点地址URL将是完全相同的链接。

However in some cases, large companies may host their WordPress site on a different server because their corporate website has many other applications, and they want to isolate where each app is hosted.

但是,在某些情况下,大型公司可能将其WordPress站点托管在其他服务器上,因为它们的公司网站还有许多其他应用程序,并且他们想隔离每个应用程序的托管位置。

But for majority of users, these two WordPress URLs need to stay the same.

但是对于大多数用户而言,这两个WordPress URL需要保持不变。

That being said, let’s take a look at how to easily change WordPress site URLs. We will show you the following methods, and you can choose the one that works best for you.

话虽如此,让我们看一下如何轻松更改WordPress网站URL。 我们将向您展示以下方法,您可以选择最适合自己的一种。

Ready? let’s get started.

准备? 让我们开始吧。

方法1.从管理区域更改WordPress网站URL (Method 1. Change WordPress Site URLs from Admin Area)

This method is the easiest. If you can already access the WordPress admin area, then we recommend using this method.

这种方法是最简单的。 如果您已经可以访问WordPress管理区域 ,那么我们建议您使用此方法。

Simply login to your WordPress website and go to Settings » General page. From here you can change WordPress site URLs under the ‘WordPress Address’ and ‘Site Address’ options.

只需登录您的WordPress网站,然后转到“设置”»“常规”页面。 在这里,您可以在“ WordPress地址”和“站点地址”选项下更改WordPress网站URL。

Change WordPress site URLs in the admin area

WordPress Address and Site Address are usually the same address.

WordPress地址和站点地址通常是相同的地址。

Don’t forget to click on the ‘Save Changes’ button to store your settings. You can now visit your website to make sure that everything is working OK.

不要忘记点击“保存更改”按钮来保存您的设置。 现在,您可以访问您的网站,以确保一切正常。

方法2。使用functions.php文件更改WordPress网站URL (Method 2. Change WordPress Site URLs Using functions.php File)

This method is recommended for users who cannot access the admin area of their WordPress website.

建议无法访问其WordPress网站管理区域的用户使用此方法。

Simply connect to your WordPress site using an FTP client and go to /wp-content/themes/your-theme-folder/.

只需使用FTP客户端连接到您的WordPress网站,然后转到/ wp-content / themes / your-theme-folder /

Edit WordPress functions file

From here you need to locate the functions.php file and edit it using a plain text editor like Notepad or TextEdit.

在这里,您需要找到functions.php文件 ,并使用纯文本编辑器(如Notepad或TextEdit)对其进行编辑。

Next, you need to add the following code at the bottom:

接下来,您需要在底部添加以下代码:


update_option( 'siteurl', 'https://example.com' );
update_option( 'home', 'https://example.com' );

Don’t forget to replace https://example.com with your own site URLs. You can now save your changes and upload the file back to your website hosting using FTP.

不要忘记用您自己的网站URL替换https://example.com。 现在,您可以保存更改,然后使用FTP将文件上传回您的网站托管。

You can now visit your website to see if everything is back to normal.

现在,您可以访问您的网站,看一切是否恢复正常。

The advantage of this method is that it updates the site URLs in the database. WordPress updates the database option for site URLs every time your functions file is loaded.

此方法的优点是它更新数据库中的站点URL。 每次加载功能文件时,WordPress都会更新站点URL的数据库选项。

Once everything gets back to normal, don’t forget to remove the two lines of code from your WordPress functions file.

一旦一切恢复正常,别忘了从WordPress函数文件中删除两行代码。

方法3.使用wp-config.php文件更改WordPress网站URL (Method 3. Change WordPress Site URLs Using wp-config.php File)

This method is only recommended if you are unsure which WordPress theme you need to edit or cannot find the functions.php file.

仅当不确定要编辑哪个WordPress主题或找不到functions.php文件时,才建议使用此方法。

For this method, you will be adding the site URLs to your WordPress configuration file called wp-config.php. This file is located in the root folder of your website and contains important WordPress settings.

对于此方法,您将站点URL添加到名为wp-config.php的WordPress配置文件中。 此文件位于您网站的根文件夹中,并且包含重要的WordPress设置。

Simply connect to your website using an FTP client and edit the wp-config file. You need to add the following code just above the line that says ‘That’s all, stop editing! Happy publishing’.

只需使用FTP客户端连接到您的网站并编辑wp-config文件 。 您需要在以下代码行的上方添加以下代码: “就这样,停止编辑! 祝您出版愉快”


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

Don’t forget to replace https://example.com with your own domain name.

不要忘记用您自己的域名替换https://example.com。

You can now save your changes and upload them back to your server. After that, visit your website to make sure that everything is working fine.

现在,您可以保存所做的更改,并将其上传回服务器。 之后,请访问您的网站以确保一切正常。

方法4.使用phpMyAdmin更改数据库中的WordPress网站URL (Method 4. Change WordPress Site URLs in the Database Using phpMyAdmin)

Another way to update WordPress site URLs is by changing them directly in your WordPress database.

更新WordPress网站网址的另一种方法是直接在WordPress数据库中更改它们。

First, you need to make a WordPress database backup. This step is really important and will help you undo database changes in case anything goes wrong.

首先,您需要进行WordPress数据库备份 。 此步骤非常重要,可以在发生任何问题时帮助您撤消数据库更改。

After that, you need to go to your web hosting account’s dashboard and click on the phpMyAdmin icon under the Databases section.

之后,您需要转到您的虚拟主机帐户的仪表板,然后单击“数据库”部分下的phpMyAdmin图标。

Note: Our screenshot is from Bluehost but most other WordPress hosting companies will also have the ability for you to edit database settings.

注意:我们的屏幕截图来自Bluehost,但是大多数其他WordPress托管公司也将具有编辑数据库设置的功能。

phpMyAdmin

Once you click the link, it will launch the phpMyAdmin app, which provides a web-based interface to edit MySQL databases. To learn more about it, see our guide on how to WordPress database management with phpMyAdmin

单击链接后,它将启动phpMyAdmin应用程序,该应用程序提供了基于Web的界面来编辑MySQL数据库。 要了解更多信息,请参阅有关如何使用phpMyAdmin进行WordPress数据库管理的指南。

Inside phpMyAdmin interface, you need to click on your WordPress database from the left column. The app will now display tables inside your WordPress database.

在phpMyAdmin界面中,您需要单击左栏中的WordPress数据库。 该应用程序现在将在WordPress数据库中显示表格。

Edit options table

Next, you need to scroll down to the options table. By default the database prefix is wp_ but since you can change WordPress database prefix, your screenshot may have a different prefix.

接下来,您需要向下滚动到选项表。 默认情况下,数据库前缀为wp_,但由于您可以更改WordPress数据库前缀 ,因此您的屏幕截图可能具有不同的前缀。

PhpMyAdmin will now display the rows inside the options table. You need to locate the rows where option_name is siteurl and home.

现在,PhpMyAdmin将显示选项表中的行。 您需要找到option_name为siteurl和home的行。

Edit siteurl and home values

Next, click on the pencil icon on the left to edit each row and change the option_value field to the new site URL. After that, click on the tiny Go button at the bottom right corner to save your database changes.

接下来,单击左侧的铅笔图标以编辑每一行,并将option_value字段更改为新的站点URL。 之后,单击右下角的小Go按钮保存您的数据库更改。

Edit option_value

You can now visit your website to see if everything is working fine.

现在,您可以访问您的网站,看一切是否正常。

常见问题(FAQ) (Frequently Asked Questions (FAQs))

Over the years we have helped hundreds of thousands of users create a WordPress website, start a blog, or start an online store. In this time, we have answered many different questions related to changing WordPress URLs. Below are some of the most frequently asked questions.

多年来,我们已经帮助成千上万的用户创建了WordPress网站创建 博客开设在线商店 。 这一次,我们回答了许多与更改WordPress URL相关的问题。 以下是一些最常见的问题。

Why are my WordPress Address and Site Address fields greyed out?

为什么我的WordPress地址和站点地址字段显示为灰色?

If the WordPress address (URL) is greyed out on the settings page of your admin area, then it means that the URLs are hard coded in the wp-config.php file.

如果WordPress地址(URL)在您管理区域的设置页面上显示为灰色,则表明这些URL硬编码在wp-config.php文件中。

WordPress Address URL Greyed Out

To change your WordPress URL, you will need to follow method 3 in our article to edit the wp-config.php file and change the URL accordingly.

要更改您的WordPress URL,您将需要按照本文中的方法3编辑wp-config.php文件并相应地更改URL。

How to recover WordPress after url address change in settings?

更改网址设置后如何恢复WordPress?

Sometimes non-techy users can accidentally change WordPress URL and Site Address settings from the WordPress admin area. To recover from that, you will have to follow our guide above to change the WordPress URLs back using functions.php, wp-config, or the database method.

有时,非技术用户可以在WordPress管理区域中意外更改WordPress URL和站点地址设置。 为了从中恢复过来,您将必须按照上面的指南,使用functions.php,wp-config或数据库方法将WordPress URL改回原来的位置。

Is there a WordPress change URL plugin that can bulk update URLs in all blog posts, pages, and other content areas?

是否有一个WordPress更改URL插件可以批量更新所有博客文章,页面和其他内容区域中的URL?

Yes, you can either use the Velvet Blues Update URLs plugin or the Better Search Replace plugin.

是的,您可以使用Velvet Blues Update URLs插件或Better Search Replace插件。

When you change your WordPress URL, you will need a way to bulk update links through your WordPress posts, pages, and other areas in your database. The above plugins are a huge time saver.

更改WordPress URL时,您将需要一种方法来通过WordPress帖子,页面和数据库中的其他区域批量更新链接。 上面的插件可以节省大量时间。

Aside from using them to update URLs when moving websites, we also use them for various other platform migrations such as moving from WordPress.com to WordPress.org, Blogger to WordPress, Weebly to WordPress, etc.

除了在移动网站时使用它们更新URL之外,我们还将它们用于其他各种平台迁移,例如从WordPress.com迁移到WordPress.org Blogger迁移到WordPress Weebly迁移到WordPress等。

We hope this article helped you easily change the WordPress site URLs. You may also want to see our guide on the must have WordPress plugins, and how to speed up WordPress.

我们希望本文能帮助您轻松更改WordPress网站URL。 您可能还希望查看有关必须具有WordPress插件的指南,以及如何加快WordPress的指南

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-change-your-wordpress-site-urls-step-by-step/

url wordpress

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值