Programming if your own server can also implement denoted domain name is good. It's not complicated, actually. You can also do a denoted domain Name System.
The key technology of denoted domain Name System is: to implement Web page redirection (redirctory). In essence, Jane
The domain Name system is completely different from the virtual machine system. The virtual domain name and IP of the virtual machine exist one by one correspondence. The denoted domain Name system does not need to do one by one mapping domain names and IP. That is, it doesn't require a complex domain name resolution mechanism or a virtual machine, and it does what it does when you request Yourname.somedomain, redirecting your browser to where you originally stored the HTML page.
The operating environment of this program is: RedHat 5.1 Linux under the Apache1.3.6 Web server +php3 language. Before we write a program, we need to set up our servers first. First, let the Apache server support PHP3. To ftp.redhat.com download mod_php-2.0.1-9.i386.rpm, after installation, modify/etc/httpd/conf/http.conf file, remove #loadmodule php3_module a line in front of the # annotation number, Also in the/etc/httpd/conf/srm.conf file, remove the #addtype application/x-httpd-php3. PhP3, and add DirectoryIndex after the INDEX.PHP3 item. Restart Apache server, at which point 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 the generic domain name. Common UNIX and Linux system DNS resolution is done by the bind daemon, Bind4 and Bind8 configuration files/etc/named.boot and name.conf respectively, configured according to your system changes. Set the configuration file for Bind/etc/named.boot, in which you add the phrase "primary domain.com Db.domain", adding a new domain record. Add in/etc/name.conf:
Zone "domain.com" {
Type master;
File "Db.domain"; };
Create a new primary domain record file Db.domain in/var/name/in the format:
N SOA dns.domain.com root.domain.com (
199811291; Serial
28800 refresh;
7200; retry.
604800; expire.
86400); minimum
Dns
MX Ten dns.domain.com.
DNS A 202.115.135.50
www A 202.115.135.50
* A 202.115.135.50
The key is the last sentence, which points to the same IP for all hostname that may be unmarked throughout the domain. Perform/USR/SBIN/NDC reload and reload the domain name database. Test, at this time should be ping a domain of the host (except already marked), all point to the specified IP, then the DNS server settings completed.
The final step is to compile the PHP3 script. We have just explained the whole principle in detail in the diagram, so it is not very difficult to write a redirect program.
Let's look at a complete HTTP header message sent by IE5.0:
user-agent:mozilla/4.0 (compatible; MSIE 5.0b1; Windows 98)
We need to remove the host information from the entire HTTP header information and then separate the first part of the http://www.jj.jx.cn/www.xxx.xxx/default.htm form, "www", that is, the hostname (name of the user registry). , as a keyword for redirection retrieval.
After retrieving the user's registered URL information, we send a redirect command "localtion:http://www.jj.jx.cn/somewhere/sample.html" to the user's browser to redirect the user to the specified page.
In PHP3, there is a function getallheader (), which gets the HTTP header information that the browser sends out. We basically need to use this function to complete the program.
The source program is attached to the back because it is only experimental nature, so in the query user information, do not use the database, if the entire system to the actual application, must be linked to the database, or query the user information process will be very long, greatly affect efficiency, and user data management is not convenient.
In the source program, all user information is recorded in the User.dat file in the data subdirectory. The format is:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.