Home Backend Development PHP Tutorial Implementation of domain name redirection system_PHP tutorial

Implementation of domain name redirection system_PHP tutorial

Jul 13, 2016 pm 05:12 PM
web The essential domain name accomplish technology of Redirect

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>
this.location ="dns.php?url="+this.location.href;
</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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629486.htmlTechArticleThe key technology of the domain name redirection system is: realizing the redirection of Web pages (Redirectory). In essence, domain name redirection systems are completely different from virtual machine systems. The virtual domain name of the virtual machine and...
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 Article Tags

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)

How to implement dual WeChat login on Huawei mobile phones? How to implement dual WeChat login on Huawei mobile phones? Mar 24, 2024 am 11:27 AM

How to implement dual WeChat login on Huawei mobile phones?

The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora? The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora? Mar 06, 2024 pm 05:34 PM

The Stable Diffusion 3 paper is finally released, and the architectural details are revealed. Will it help to reproduce Sora?

DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! Mar 21, 2024 pm 05:21 PM

DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book!

How to implement the WeChat clone function on Huawei mobile phones How to implement the WeChat clone function on Huawei mobile phones Mar 24, 2024 pm 06:03 PM

How to implement the WeChat clone function on Huawei mobile phones

PHP Programming Guide: Methods to Implement Fibonacci Sequence PHP Programming Guide: Methods to Implement Fibonacci Sequence Mar 20, 2024 pm 04:54 PM

PHP Programming Guide: Methods to Implement Fibonacci Sequence

PHP Game Requirements Implementation Guide PHP Game Requirements Implementation Guide Mar 11, 2024 am 08:45 AM

PHP Game Requirements Implementation Guide

Master how Golang enables game development possibilities Master how Golang enables game development possibilities Mar 16, 2024 pm 12:57 PM

Master how Golang enables game development possibilities

How to register a corporate email domain name How to register a corporate email domain name May 07, 2024 pm 01:48 PM

How to register a corporate email domain name

See all articles