Home Backend Development PHP Tutorial How to develop a virtual domain name system_PHP tutorial

How to develop a virtual domain name system_PHP tutorial

Jul 21, 2016 pm 04:02 PM
use exist domain name how develop hour of system virtual

Everyone feels very convenient when using abbreviated domain names such as yourname.yeah.net. Many people are thinking: If only I could enable my own server to implement abbreviated domain names. Actually it's not complicated. After reading this article, you can also create an abbreviated domain name system.

The key technology of the abbreviated domain name system is to realize the redirection of Web pages (Redirectory). In essence, abbreviated domain name systems and virtual machine systems are completely different. There is a one-to-one correspondence between the virtual domain name and IP of the virtual machine. The abbreviated domain name system does not require one-to-one mapping of domain names and IPs. In other words, it does not require complex domain name resolution mechanisms and virtual machines to complete at all. What it does is when you request yourname.somedomain, redirect your browser to the place where you originally stored the Html page.

In order to explain more completely, the following legend is:

The source program I provide is the running environment: Apache1.3.6 Web server + PHP3 language under RedHat 5.1 Linux. Before writing the program, we first need to set up our server. First, let the Apache server support php3. Go to ftp.redhat.com to download mod_php-2.0.1-9.i386.rpm. After installation, modify the /etc/httpd/conf/http.conf file and remove the # comment in front of the #LoadModule php3_module sentence, also in /etc Remove the comment number in front of #AddType application/x-httpd-php3 .php3 in the /httpd/conf/srm.conf file, and add index.php3 after the DirectoryIndex item. Restart Apache Server. At this time, the server supports standard php3 language script files and can use index.php3 as the default home page.
Set up the DNS server so that it can resolve pan-domain names. DNS resolution in general Unix and Linux systems is completed by the Bind daemon. The configuration files of Bind4 and Bind8 are /etc/named.boot and name.conf respectively. Modify them according to your system during configuration. Set the Bind configuration file /etc/named.boot, add the sentence "primary domain.com db.domain" to it, and add a new domain record. Add to /etc/name.conf:

zone "domain.com" {
type master;
file "db.domain";
};
in /var Create a new main domain record file db.domain in /name/, its format is:
N SOA dns.domain.com root.domain.com (
199811291 ; Serial
28800 ; refresh
7200 ; retry
604800 ;expire
86400) ;minimum
dns
MX 10 dns.domain.com. 5.135.50 
 * A 202.115.135.50
The key is the last sentence, that is, all unmarked Hostnames in the entire domain may point to the same IP. Execute /usr/sbin/ndc reload to reload the domain name database. Test it. At this time, you should ping any host in the domain (except those that have been marked), and all point to the specified IP. Then the DNS server setting is completed.


The last step is to compile the PHP3 script. We have just explained the entire principle in detail in the figure, so it is not difficult to write a redirection program.


Let’s take a look at a complete HTTP header sent by IE5.0:


Accept: application/vnd.ms-excel, application/msword, application/ vnd.ms-powerpoint, Image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-cn
Connection: Keep-Alive
Host: ww.yahoo.com
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0b1; Windows 98)
We need to remove the Host information from the entire HTTP header. Then take out the first part "www" in the form of http://www.jj.jx.cn/www.xxx.xxx/default.htm, that is, HostName (that is, the name registered by the user) separately, as a redirect retrieval Keywords.


After retrieving the user's registered URL information, we send a redirection command "Localtion: http://www.jj.jx.cn/somewhere/sample.html" to the user's browser. Redirect the user to the specified page.


In PHP3, there is the function GetAllHeader() to obtain the HTTP header information sent by the browser. We mainly need to use this function to complete the entire program.


The source program is attached at the end. Since it is only experimental, the database is not used when querying user information. If the entire system is to be put into practical use, it must be connected to the database, otherwise the query The process of user information will be very long, greatly affecting efficiency, and the management of user data will be inconvenient. (Due to space limitations, the writing record program required for registration and management is not given, please add it yourself)


In the source program, all user information is recorded in the user.dat file under the data subdirectory. .其格式为:  


  username:  


  http://octopus.cdit.edu.cn/~qap213/index.html  


  附PHP3源程序:  


  

  //Get HTTP's Header and parse it//  


  $headers = getallheaders();  


  while (list($header, $value) = each($headers)) {  


  if($header=="Host"){$username= strtok($value,".");}}  


  //Jump out the Banner's Window//  


  echo '';  


   

  // seek the user information from the recorded file//  


  if(!$usrinfo=file("data/user.dat")){echo "Open Data File Error!!";}  


  $url="http://";  


  for($i=0;$i

  if(strtok($usrinfo[$i],":")==$username){  


  $url=$usrinfo[$i+1];  


  }  


  if($url=="http://"){echo "not found the uesrname of Data!";}  


  else{  


  echo '';}  


  ?>  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316490.htmlTechArticle大家在使用诸如yourname.yeah.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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CUDA's universal matrix multiplication: from entry to proficiency! CUDA's universal matrix multiplication: from entry to proficiency! Mar 25, 2024 pm 12:30 PM

General Matrix Multiplication (GEMM) is a vital part of many applications and algorithms, and is also one of the important indicators for evaluating computer hardware performance. In-depth research and optimization of the implementation of GEMM can help us better understand high-performance computing and the relationship between software and hardware systems. In computer science, effective optimization of GEMM can increase computing speed and save resources, which is crucial to improving the overall performance of a computer system. An in-depth understanding of the working principle and optimization method of GEMM will help us better utilize the potential of modern computing hardware and provide more efficient solutions for various complex computing tasks. By optimizing the performance of GEMM

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Jul 30, 2024 pm 02:17 PM

On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

See all articles