ad域 父域 管理 子域_如何正确地将WordPress从子域移动到根域

ad域 父域 管理 子域

Do you want to move a WordPress site from subdomain to root domain? The process is fairly easy to follow, and there is a way to save your SEO rankings as well. In this article, we will show you how to easily move WordPress from subdomain to root domain with step by step instructions.

您是否要将WordPress网站从子域移动到根域? 该过程相当容易遵循,并且还有一种方法可以保存您的SEO排名。 在本文中,我们将向您展示如何通过分步说明轻松地将WordPress从子域移动到根域。

Moving a WordPress site from subdomain to root domain

将WordPress从子域转移到根域 (Transferring WordPress from Subdomain to Root Domain)

A subdomain is an extension of your root domain name. For example, http://yourwebsite.example.com is a subdomain of example.com. In this case, example.com is the root domain.

子域是您的根域名的扩展。 例如,http://yourwebsite.example.com是example.com的子域。 在这种情况下,example.com是根域。

Search engines consider subdomain to be a totally different website. This is why you need to make sure that you properly redirect search engines to the root domain after the transfer. This will help you preserve search rankings after moving your website.

搜索引擎认为子域是一个完全不同的网站。 这就是为什么您需要确保在转移后将搜索引擎正确重定向到根域。 这将帮助您在移动网站后保留搜索排名。

Unlike moving a WordPress site to new host or a new domain name, moving a site to root domain is a bit easier.

将WordPress网站移至新主机新域名不同 ,将网站移至根域要容易一些。

Primarily because both are usually hosted with the same web hosting company. This allows you to skip a few steps.

主要是因为两者通常都由同一网络托管公司托管。 这使您可以跳过一些步骤。

Let’s take a look at how to move a WordPress site from subdomain to root domain.

让我们看一下如何将WordPress网站从子域移动到根域。

步骤1.创建网站的完整备份 (Step 1. Create a Complete Backup of Your Website)

You should always keep a backup solution installed on your website for automated backups. There are plenty of WordPress backup plugins that you can use to keep your WordPress content safe.

您应该始终在网站上安装备份解决方案以进行自动备份。 您可以使用许多WordPress备份插件来确保WordPress内容的安全。

Now if you already have a backup plugin installed, then you may be thinking that you can skip this step.

现在,如果您已经安装了备份插件,那么您可能会认为可以跳过此步骤。

This step is to remind you that even if you have automated backups of your website, you still need to create a complete backup of your site. This includes a database backup as well as a backup of all your WordPress files and folders.

此步骤旨在提醒您,即使您具有网站的自动备份,您仍然需要创建网站的完整备份 。 这包括数据库备份以及所有WordPress文件和文件夹的备份。

Once you have created a complete backup, make sure that you store it on a remote location or on your computer.

创建完整的备份后,请确保将其存储在远程位置或计算机上。

步骤2.将WordPress文件从子域移动到根文件夹 (Step 2. Moving Your WordPress Files From Subdomain to Root Folder)

First you need to connect to your website using a FTP client or cPanel’s file manager. Once connected, go to your subfolder location and download all your WordPress files to your computer.

首先,您需要使用FTP客户端或cPanel的文件管理器连接到您的网站。 连接后,转到子文件夹位置,然后将所有WordPress文件下载到计算机上。

Download WordPress files

Next, open the public_html folder of your root domain. Depending on how your WordPress hosting environment is setup, this folder could also be named www or after your domain name.

接下来,打开您的根域的public_html文件夹。 根据您的WordPress托管环境的设置方式,此文件夹也可以命名为www或以您的域名命名。

Now, you need to upload all WordPress files you downloaded earlier to the root directory.

现在,您需要将之前下载的所有WordPress文件上传到根目录。

Upload WordPress files to root domain

步骤3.更改WordPress URL和站点URL设置 (Step 3. Change WordPress URL and Site URL Settings)

Once you move the WordPress files, you will not be able to access the WordPress admin area on the root domain. Trying to login to the root website will send you back to the subdomain website’s admin area.

移动WordPress文件后,您将无法访问根域上的WordPress管理区域。 尝试登录到根网站将使您返回到子域网站的管理区域。

To fix this, switch to the FTP client and go to the root directory of your domain name. Next, you need to edit the wp-config.php file and add the following lines just before the line ‘That’s all, stop editing! Happy blogging’.

要解决此问题,请切换到FTP客户端,然后转到域名的根目录。 接下来,您需要编辑wp-config.php文件,并在“就此停止编辑! 祝您博客愉快”。


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

Don’t forget to replace example.com with your own domain name. If you want your root website to use www then you will need to enter the URLs with www prefix.

不要忘记用您自己的域名替换example.com。 如果您希望根网站使用www,则需要输入带有www前缀的URL。

Save your changes and upload the wp-config.php file back to your website.

保存您的更改,并将wp-config.php文件上传回您的网站。

You can now visit your WordPress site’s admin area on the root domain name.

您现在可以在根域名上访问WordPress网站的管理区域。

步骤4.更新URL (Step 4. Update URLs)

Your WordPress site has moved to the root domain, but there will be links inside your WordPress database pointing to the subdomain.

您的WordPress网站已移至根域,但WordPress数据库中将有指向子域的链接。

Let’s fix that.

让我们修复它。

You will need to install and activate the Velvet Blues Update URLs plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您将需要安装并激活Velvet Blues Update URLs插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Tools » Update URLs page.

激活后,您需要访问工具»更新URL页面。

Update URLs

On this page, you need to enter your subdomain url next to the Old URL option and add your root domain as the new URL. Next, under the ‘Choose which URLs should be updated’ area, you need to check all options except ‘All GUIDs’.

在此页面上,您需要在“旧UR​​L”选项旁边输入您的子域URL,并将您的根域添加为新URL。 接下来,在“选择应更新的URL”区域下,您需要检查除“所有GUID”以外的所有选项。

Once you are done, click on the ‘Update URLs Now’ button to continue.

完成后,单击“立即更新URL”按钮以继续。

The plugin will now update all URLs in your WordPress database. This may take some time. Once finished, you will see a success message.

现在,该插件将更新WordPress数据库中的所有URL。 这可能要花点时间。 完成后,您将看到一条成功消息。

步骤5.将所有子域流量重定向到根域 (Step 5. Redirect All Subdomain Traffic to The Root Domain)

Now that you have moved WordPress files, let’s make sure that your subdomain traffic is redirected to the root domain name.

现在您已经移动了WordPress文件,让我们确保您的子域访问量已重定向到根域名。

Go to your subdomain folder and make sure that hidden files are forced to be visible.

转到您的子域文件夹,并确保隐藏文件被强制可见。

Your FTP client settings have an option to always show hidden files. In FileZilla, it is located under ‘Server > Force Showing Hidden Files’ option.

您的FTP客户端设置具有始终显示隐藏文件的选项。 在FileZilla中,它位于“服务器>强制显示隐藏文件”选项下。

Show hidden files

If you are using cPanel File Manager, then click on the Settings button at the top right corner of the screen. This will bring up the preferences popup. You need to select ‘Show hidden files’ and then click on the save button.

如果您使用的是cPanel File Manager,则单击屏幕右上角的“设置”按钮。 这将弹出首选项弹出窗口。 您需要选择“显示隐藏文件”,然后单击“保存”按钮。

Show hidden files in cPanel file manager

If your subdomain folder already has a .htaccess file, then you can delete it and create a new one. Inside the new .htaccess file, you need to copy and paste the following code:

如果您的子域文件夹已经具有.htaccess文件 ,则可以将其删除并创建一个新文件。 在新的.htaccess文件中,您需要复制并粘贴以下代码:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursubdomain\.example\.com$ [NC]
RewriteRule ^(.*)$ "http://example.com/$1" [R=301,L]
</IfModule>

Don’t forget to replace yoursubdomain with your actual subdomain, and example.com with your domain name.

不要忘记用实际的子域名替换yoursubdomain,用域名替换example.com。

Please note that the RewriteRule line uses a non-www URL. If you want to use www in your root domain, then you will need to add your URL with a www prefix.

请注意,RewriteRule行使用非www URL 。 如果要在根域中使用www,则需要添加带有www前缀的URL。

Save your changes and upload your .htaccess file to the server.

保存更改,然后将.htaccess文件上载到服务器。

That’s all, you have successfully moved your site from subdomain to root domain. You can now visit your website to see it in action. Test out your website to make sure that everything is working fine.

就是这样,您已经成功将站点从子域移到了根域。 现在,您可以访问您的网站以查看其运行情况。 测试您的网站,以确保一切正常。

We hope this article helped you move your site from subdomain to root domain. You may also want to see our ultimate WordPress SEO guide for beginners.

我们希望本文能帮助您将网站从子域移到根域。 您可能还希望查看针对初学者的终极WordPress SEO指南

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-properly-move-wordpress-from-subdomain-to-root-domain/

ad域 父域 管理 子域

  • 0
    点赞
  • 0
    收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值