search
HomeCMS TutorialWordPressAbout simultaneous access inside and outside WordPress LAN

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

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!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
How easy is it to manage content with WordPress?How easy is it to manage content with WordPress?May 09, 2025 am 12:11 AM

WordPressisuser-friendlyduetoitsintuitiveinterfaceandCMS,whichseparatescontentfromdesign.Itoffersarichtexteditorforeasycontentcreationandamedialibraryfororganization.Itsflexibilityisenhancedbynumerousthemesandplugins,thoughoverusecanimpactperformance

How is WordPress used in business settings?How is WordPress used in business settings?May 08, 2025 am 12:04 AM

WordPressissuitableforbusinesssettings.1)Itsupportse-commercewithpluginslikeWooCommerce,allowingproductmanagementandpaymentprocessing.2)ItservesasaCMSforcorporateblogs,enhancingSEOandengagement.3)Customizationispossiblewithnumerousthemesandplugins.4)

What types of websites are not a good fit for WordPress?What types of websites are not a good fit for WordPress?May 07, 2025 am 12:10 AM

WordPressisnotidealforhigh-trafficwebsites,customandcomplexapplications,security-sensitiveapplications,real-timedataprocessing,andhighlycustomizeduserinterfaces.Forhigh-trafficsites,useNext.jsorcustomsolutions;forcomplexapplications,optforDjangoorRub

Can you build a blog with WordPress?Can you build a blog with WordPress?May 06, 2025 am 12:03 AM

Yes,youcanbuildablogwithWordPress.1)ChoosebetweenWordPress.comforbeginnersorWordPress.orgformorecontrol.2)Selectathemetopersonalizeyourblog'slook.3)Usepluginstoenhancefunctionality,likeSEOandsocialmediaintegration.4)Customizeyourthemewithsimplecodetw

How secure is WordPress as a CMS platform?How secure is WordPress as a CMS platform?May 05, 2025 am 12:01 AM

WordPresscanbesecureifmanagedproperly.1)KeeptheWordPresscoreupdatedtopatchvulnerabilities.2)Vetandupdatepluginsandthemesfromreputablesources.3)Enforcestrongpasswordsandusetwo-factorauthentication.4)Chooseahostingproviderwithgoodsecuritypractices.5)Ed

What kind of websites can you build with WordPress CMS?What kind of websites can you build with WordPress CMS?May 04, 2025 am 12:06 AM

WordPresscanbuildvarioustypesofwebsites:1)Personalblogs,easytosetupwiththemesandplugins.2)Businesswebsites,usingdrag-and-dropbuilders.3)E-commerceplatforms,withWooCommerceforseamlessintegration.4)Communitysites,usingBuddyPressorbbPress.5)Educationalp

What are the pros and cons of using WordPress as your CMS?What are the pros and cons of using WordPress as your CMS?May 03, 2025 am 12:09 AM

WordPressisapowerfulCMSwithsignificantadvantagesandchallenges.1)It'suser-friendlyandcustomizable,idealforbeginners.2)Itsflexibilitycanleadtositebloatandsecurityissuesifnotmanagedproperly.3)Regularupdatesandperformanceoptimizationsarenecessarytomainta

How does WordPress compare to other popular CMS platforms?How does WordPress compare to other popular CMS platforms?May 02, 2025 am 12:18 AM

WordPressexcelsineaseofuseandadaptability,makingitidealforbeginnersandsmalltomedium-sizedbusinesses.1)EaseofUse:WordPressisuser-friendly.2)Security:Drupalleadswithstrongsecurityfeatures.3)Performance:GhostoffersexcellentperformanceduetoNode.js.4)Scal

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools