DNS for two-level domain name

zhaozj2021-02-11  225

As a problem that small companies often encounter, it is necessary to open the secondary domain name and don't want to always pass IDC. Because the efficiency of IDC is not compliment, and the attitude of IDC often makes people think. . . . . .

My company is in the IDC to rent a server (only two IP addresses, very pitiful, IDC to be 200RMB an IP), because the company's input is limited, refuses to rent a little. Now, I ran on the server and DB Server. If you add DNS, you don't know if this 2U's guy can live in the top, so I simply don't have DNS services, and give our company DNS resolution to IDC. Although a server is saved, the trouble is also coming, the company often wants the second-level domain name (such as our company's domain name is www.ordomain.com, often need to open a secondary domain name similar to forum.orin.com), The times and IDC negotiations, I really make me very difficult (sometimes IDC salesperson also wants 50 RMB a secondary domain name). So I finally made a small program to parse our secondary domain name.

The principle of parsing is this: ServerVariables ("http_host") This variable can return the address of the user request (such as www.otomain.com or forum.orrDomain.com, may also be your IP address) and then we can use this For the basis for parsing! Below is the parsed applet:

Redirect.asp:

<%

'What is the address of the user request?

RequireURL = Request.ServerVariables ("http_host")

'Redirect it according to the address requested by the user

SELECT CASE REQUIREURL

Case "cad.otomain.com" response.Redirect "http://www.otomain.com/cad/"

Case "forum.otomain.com" response.Redirect "http://www.otomain.com/forum/"

'If you are other requests to go to the company's WWW domain name (you can also set to reject other requests)

Case else response.Redirect "http://www.otomain.com/index.asp"

End SELECT

%>

Ok, the order in which IIS's default document is changed to redirect.asp / index.asp, so users will first access your redirect files when they visit your website, and then go to your desirable address!

On the redirection process, if you think the redirect waste resources, you can use Script to complete: