如何开发一个虚拟域名系统_PHP
大家在使用诸如yourname.yeah.net这样的简记域名时都感到十分方便,有很多人在想:我要是能让自己的服务器也能够实现简记域名就好了。其实这并不复杂。看完了本文,你也可以做一个简记域名系统。
简记域名系统的关键技术在于:实现Web页面的重定向(Redirctory)。在本质上,简记域名系统和虚拟机系统完全不同。虚拟机的虚拟域名和IP是存在一一对应关系的。而简记域名系统不需要将域名和IP做一一映射。也就是说,它根本不需要复杂的域名解析机制和虚拟机来完成,它所做的事情就是当你在请求yourname.somedomain时,将你的浏览器重新定向到你本来存放Html页面的地方。
为了说明的更完善,下面图例:
我提供的源程序是运行环境是:RedHat 5.1 Linux下的Apache1.3.6 Web服务器+PHP3语言。 在编写程序之前,我们首先要设置好我们的服务器。首先要让Apache服务器支持php3。到ftp.redhat.com下载mod_php-2.0.1-9.i386.rpm,安装后,修改/etc/httpd/conf/http.conf文件,去掉
设置DNS服务器,使其能对泛域名解析。一般的Unix和Linux系统的DNS解析都是由Bind守护程序完成的,Bind4和Bind8的配置文件分别/etc/named.boot和name.conf,配置时根据你的系统修改。设置Bind的配置文件/etc/named.boot,在其中加入“primary domain.com db.domain”一句,添加一个新的域记录。在/etc/name.conf中加入:
zone "domain.com" {
type master;
file "db.domain”;
};
在/var/name/中新建主域记录文件db.domain,其格式为:
N SOA dns.domain.com root.domain.com (
199811291 ;Serial
28800 ;refresh
7200 ;retry
604800 ;expire
86400) ;minimum
dns
MX 10 dns.domain.com.
dns A 202.115.135.50
www A 202.115.135.50
* A 202.115.135.50
关键是最后一句,即将整个域可能出现未做标记的所有Hostname全部指向同一IP。 执行/usr/sbin/ndc reload,重新加载域名数据库。测试一下,此时应该随便ping一个domain域内的主机(除已经标记的),都指向了指定的IP,那么DNS服务器设置完成。
最后一步是编制PHP3脚本。我们刚才已经在图中详细的说明了整个的原理,所以写一个重新定向的程序就不是很难了。
让我们来看一个由IE5.0送出的完整HTTP头信息:
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)
我们需要在整个HTTP头信息中取出Host信息,然后将http://www.jj.jx.cn/www.xxx.xxx/default.htm形式的第一部分“www”,即HostName(也即是用户注册的name)单独取出,作为重定向检索的关键字。
检索到用户注册的URL信息后,我们给用户浏览器送一个重定向命令“Localtion: http://www.jj.jx.cn/somewhere/sample.html”,将用户重定向到指定页面。
在PHP3中,有函数GetAllHeader(),取得浏览器送出的HTTP头信息。我们主要需要使用此函数来完成整个程序。
后面附有源程序,由于只是实验性质的,所以在查询用户信息时,没有使用数据库,如果整个系统要实际应用的话,一定要和数据库挂接起来,不然查询用户信息的过程将是十分漫长,大大影响效率,而且用户数据的管理也不方便。(由于篇幅限制,没有给出注册和管理所需的写记录程序,请自行添加)
在源程序中,所有用户信息记录在data子目录下user.dat文件中。其格式为:
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 '';}
?>
摘自:http://www.zphp.com/power/tech_articles/list.php?id=212

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



With the rapid development of social media, Xiaohongshu has become one of the most popular social platforms. Users can create a Xiaohongshu account to show their personal identity and communicate and interact with other users. If you need to find a user’s Xiaohongshu number, you can follow these simple steps. 1. How to use Xiaohongshu account to find users? 1. Open the Xiaohongshu APP, click the "Discover" button in the lower right corner, and then select the "Notes" option. 2. In the note list, find the note posted by the user you want to find. Click to enter the note details page. 3. On the note details page, click the "Follow" button below the user's avatar to enter the user's personal homepage. 4. In the upper right corner of the user's personal homepage, click the three-dot button and select "Personal Information"

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

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

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

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

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

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

Recently, Huawei announced that it will launch a new smart wearable product equipped with Xuanji sensing system in September, which is expected to be Huawei's latest smart watch. This new product will integrate advanced emotional health monitoring functions. The Xuanji Perception System provides users with a comprehensive health assessment with its six characteristics - accuracy, comprehensiveness, speed, flexibility, openness and scalability. The system uses a super-sensing module and optimizes the multi-channel optical path architecture technology, which greatly improves the monitoring accuracy of basic indicators such as heart rate, blood oxygen and respiration rate. In addition, the Xuanji Sensing System has also expanded the research on emotional states based on heart rate data. It is not limited to physiological indicators, but can also evaluate the user's emotional state and stress level. It supports the monitoring of more than 60 sports health indicators, covering cardiovascular, respiratory, neurological, endocrine,
