Home > CMS Tutorial > WordPress > body text

About simultaneous access inside and outside WordPress LAN

藏色散人
Release: 2021-03-05 15:55:34
forward
4152 people have browsed it

The following tutorial column of WordPress will introduce to you about simultaneous access inside and outside the WordPress LAN. I hope it will be helpful to friends in need!

My configuration environment:

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

Use the peanut shell dynamic domain name to update the IP to your own domain name. nginx configures the virtual host LAN external port 23456, the LAN internal port 80, and the homepage directory is the same.
WordPress is placed in the wordpress folder in the root directory of the website. In the setting interface, both siteurl and home are set to http://www.xxx.cn:23456/wordpress
. There is no problem when accessing from the external network. However, it is not possible to access http://www.xxx.cn:23456/wordpress from the internal network. Even if you open it, you can't access 192.168.1.100/wordpress.
According to the online method, modify the siteurl and home in the database to /wordpress. Access outside the LAN is not normal (some pages can be opened, such as the administrator interface, but the homepage cannot be opened).

My solution:

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

This is just an idea and can be modified according to specific circumstances. For example, if you don't use a special port, you can directly write lines 4, 5, and 6 as line 5.

function get_option( $option, $default = false ) {                          //自己写一个get_option函数
	$my_option=my_get_option($option,$default);                         //调用原来的函数
	if($option=="siteurl" || $option == "home"){                        //针对siteurl和home做修改,其他不变
		if($_SERVER['HTTP_HOST']!="www.xxx.cn"){                  //如果不是用域名访问的
		$my_option="http://".$_SERVER['HTTP_HOST']."/wordpress";  //就跳转到当前URL里的服务器地址,比如本地的localhost或局域网访问的192.168.1.100
		}
	}
	return $my_option;
}


function my_get_option( $option, $default = false ) {                       //将原来的get_option函数名称改成my_get_option
Copy after login

The above is the detailed content of About simultaneous access inside and outside WordPress LAN. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!