Home >CMS Tutorial >WordPress >How does WordPress automatically redirect to the old port after changing the port?

How does WordPress automatically redirect to the old port after changing the port?

藏色散人
藏色散人forward
2021-03-16 17:35:323456browse

The following tutorial column of WordPress will introduce to you how WordPress will automatically jump to the old port after changing the port. I hope it will be helpful to friends in need!

How does WordPress automatically redirect to the old port after changing the port?

After WordPress changes the port, access will automatically jump to the old port

When you first install the wordpress program, nginx configuration The port is 8081.

After starting the nginx and php services, visit http://www.example.com:8081/wp-admin to start the gradual installation, and then successfully build the blog website.

After the website has been running for a period of time, you need to change port 8081 to port 80. At this time, change port 8081 in the nginx configuration to port 80, and reload the nginx configuration file. Accessing the website will automatically jump to port 8081. (Old port configured last time), clearing the browser cache and restarting nginx still cannot solve the problem.

Cause of the problem:

When installing wordpress for the first time, it will Save the homepage address of the website to the WordPress database. When accessing the website in the future, the homepage address in the database shall prevail. If you individually change the access address mapped by web servers such as nginx (changes in IP, domain name, and port), it will still automatically jump to the database. Stored homepage address.

Solution:

Modify the wordpress database, wp_options table, option_name field is equal to 2 records of siteurl and home

Change The option_value value of these two records is updated to your latest changed address, for example: http://www.example.com or http://www.example.com:80

After the change is successful, you can Access the wordpress website normally through port 80

How does WordPress automatically redirect to the old port after changing the port?

MySQL operation statement:

# wp_options表 查询记录
select * from wp_options where option_name in ('siteurl','home');

# wp_options表 更新option_value的值
update wp_options set option_value='http://www.example.com:80' where option_name in ('siteurl','home');

The above is the detailed content of How does WordPress automatically redirect to the old port after changing the port?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete