The key technology of the domain name redirection system is to realize the redirection of Web pages (Redirectory). In essence, domain name redirection systems are completely different from virtual machine systems. There is a one-to-one correspondence between the virtual domain name and IP of the virtual machine. The domain name redirection 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 *.yourdomain, redirect your browser to the actual address where you store the Html page.
Let’s implement the domain name redirection system step by step:
(Assume your domain name is www.mydomain.com and the host address is 196.0.0.1).
First we need to set up DNS to point *.mydomain.com to our host address 196.0.0.1. (If you do not have your own DNS server, you can skip this step and contact your domain name service provider to ask them to help you point *.mydomain.com to 196.0.0.1)
The DNS management tool of win2000 does not allow the host to be The name is directly filled in as *, which means that we cannot directly point *.mydomain.com to the same IP address in the win2000DNS management tool. But we can achieve this by changing the winntsystem32dnsmydomain.dns file. This file is saved in text format and we can open it through WordPad.
We need to add a record of * A 196.0.0.1 at the end.
We update the server data file in the DNS management tool of WIN2000. You will find that there is an additional host "*" in the mydomain.com domain that we could not add directly. (Note: The DNS settings you make will not take effect until a few hours later.)
In order for this domain name redirection system to run on multiple platforms, we choose php+mysql to create the program part. Please check whether your web server has php installed. and mysql:
We use index.htm to read the HTTP header information sent by the browser and send it to dns.php. dns.php queries the database to get the redirection address and returns it to the client.
Create mysql database mydomain
CREATE TABLE dns (
main char(60),
link char(255)
)
main is used to save the * part of *.mydomain.com
Link is used to save the redirection address corresponding to the domain name.
Create index.htm:
<script> <br>this.location ="dns.php?url="+this.location.href; <br></script>
Yes Friends will ask why not use PHP's GetAllHeader() function to obtain the HTTP header information sent by the browser. Because the function GetAllHeader() only supports the Apache web server, I believe most win2000 users use the iis server. Considering compatibility issues, we chose to use JavaScript to read the HTTP header information sent by the browser.
Create dns.php file:
$domain="mydomain.com"; //Domain name
$database="mydomain" //Database
$datauser="root "; //Database user