WordPress更改站点地址方法及可能遇到的问题

2022/1/23:更新为 Markdown 格式。

WordPress安装后,站点地址可能会使用虚拟主机自带的临时域名,若想要更换成自己的域名地址,就需要使用域名解析。

域名解析

我这里购买的是阿里云的域名,在阿里云的域名控制台中,点击域名的解析,添加记录,然后根据虚拟主机的信息进行填写,我的虚拟主机是使用别名解析(CNAME),主机记录推荐使用
*.mwhls.top(即泛解析,可以匹配其他所有带前缀域名)
与@.mwhls.top(直接解析,无前缀)。
因此,泛解析填写如下:

虚拟主机绑定域名

之后,在虚拟主机处绑定域名,我这里是使用的酷番云的虚拟主机,添加域名处将域名添加进入即可。我使用使用mwhls.top与www.mwhls.top两个,即空前缀与www前缀。

在域名解析及绑定域名后,将虚拟主机的地址更换为绑定的域名,可进入相同界面,则绑定成功。及对于下面两个地址,进入的是相同的页面,

虚拟主机:hostvgwt3nm.host02.hostss.com.cn

域名地址:mwhls.top

站点地址更改

之后,进入后台(点击wordpress首页左上角),后打开设置中的常规,将WordPress地址(URL)及站点地址(URL)中虚拟主机的连接替换为域名。

站点地址修改之后,点击页面内的连接,就不会再转到虚拟主机的地址了。

根目录添加文件

但此时使用mwhls.top并不能进入wordpress的页面,虚拟主机的默认首页也不能指向其他文件夹中的文件,这使得想要进入博客页面,需要输mwhls.top/wordpress才能进入。但可通过在根目录添加文件解决。

将wordpress文件夹中的index.php文件复制到网站根目录,将倒数第二行的require <strong>DIR</strong> . '/wp-blog-header.php';修改为require <strong>DIR</strong> . '/wordpress/wp-blog-header.php';。并将虚拟主机默认首页设置为更改后的文件。

更换站点地址出错后的解决方法

在更改站点地址后,刷新页面后出现错误页面,说明站点地址错误,此时可以通过修改数据库恢复原页面。

即,将表wp_options中的siteurl与home字段的数据更换成正确页面的地址。

相关连接

阿里云代金券领取:https://www.aliyun.com/minisite/goods?userCode=d7szx8ov

酷番云虚拟主机+数据库免费领取:https://www.kufanyun.com/act/developer


After WordPress is installed, wordpress will using VPS temporary domain as its web site URL probably. For using our domain, we should use domain name resolution.

Domain name resolution

Open AliCloud\'s domain name console, and resolving domain name by the information of VPS.

For example, CNAME is the resolving method of my VPS, so, using *.mwhls.top and @.mwhls.top to resolve domain name.

Here is an example.

Binding domain to VPS

Then, bind domain to VPS in VPS console.

I bind mwhls.top and www.mwhls.top to my VPS according to the resolving method.

If binding processes are successful, the VPS temporary domain and your own domain will show the same web.

In the other word, the following two domain will show the same web

VPS temporary domain:
hostvgwt3nm.host02.hostss.com.cn

my domain:
mwhls.top

Web site URL changing

Entering wordpress admin page, and open OPTIONS-GENERAL. In here, update the WordPress URL and Web URL by changing VPS to your own domain.

After updating URL, checking any link in your blog will not jump to VPS temporary domain.

Adding new php file to web root

For replacing mwhls.top(my domain) with mwhls.top/wordpress as our home page, a php file which supports jumping function should add to web root.

Copy \'index.php\' in wordpress forder to web root, and replace require <strong>DIR</strong> . '/wp-blog-header.php'; with require <strong>DIR</strong> . '/wordpress/wp-blog-header.php';

Then, choose the new file as default home page in VPS console.

The method resolving an error after updating URL

If the updating url show an error, some data in DataBase should be changed.

Changing option_name: siteurl and home option_value in Table wp_options to a right url, such as mwhls.top/wordpress

Relative link

AliCloud\'s vouchers:https://www.aliyun.com/minisite/goods?userCode=d7szx8ov

Free VPS and DataBase in Kufanyun.com:https://www.kufanyun.com/act/developer

版权声明:
作者:MWHLS
链接:http://panwj.top/49.html
来源:无镣之涯
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>