Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example of simultaneous access inside and outside WordPress local area network

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you an example of simultaneous access to WordPress inside and outside the local area network, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

My configuration environment:

The server is set up on the computer at home, fixed LAN IP:192.168.1.100, using telecommunications network, public network IP, but port 80 can not be used, has its own domain name: www.xxx.cn

Use the peanut shell dynamic domain name to update IP to your own domain name. Nginx configures virtual host port 23456 outside the local area network and port 80 within the local area network, the same as the home page directory.

WordPress is placed in the wordpress folder under the root of the website. Setting interface, http://www.xxx.cn:23456/wordpress set by both siteurl and home

There is no problem with access to the public network. Access to the http://www.xxx.cn:23456/wordpress from the private network cannot be opened, and access to the 192.168.1.100/wordpress is not allowed.

According to the online method, change the siteurl and home in the database to / wordpress, and the access outside the local area network is abnormal (some pages can be opened, such as the administrator interface, but the home page cannot be opened).

My solution:

Keep the settings http://www.xxx.cn:23456/wordpress in the data unchanged. Follow the instructions below to modify the get_option function in wordpress\ wp-includes\ option.php.

This is just a train of thought, which can be modified according to the specific situation. For example, if you don't use a special port, you can directly write line 4, 5, 5, 6 as line 5.

Function get_option ($option,$default = false) {/ / write a get_option function $my_option=my_get_option ($option,$default) / / call the original function if ($option== "siteurl" | | $option== "home") {/ / make changes to siteurl and home Other unchanged if ($_ SERVER ['HTTP_HOST']! = "www.xxx.cn") {/ / if it is not a $my_option= "http://".$_SERVER['HTTP_HOST']."/wordpress"; accessed with a domain name / / just jump to the server address in the current URL, such as the local localhost or 192.168.1.100}} return $my_option for LAN access. } function my_get_option ($option, $default = false) {/ / change the original get_option function name to my_get_option or above is all the contents of the article "examples of simultaneous access inside and outside the WordPress LAN". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report