Do your own DNS for level two domain names

Source: Internet
Author: User
Tags servervariables domain
Two-level domain name as a small company often encountered the problem is the need to open a level two domain name and do not want to always through IDC, because the efficiency of IDC is really not to compliment, and IDC's attitude often let people think hard to penetrate ...

My company is in the IDC rented a server (only two IP address, very poor, IDC to 200RMB an IP), because the company's investment in this area is limited, refused to rent a little more. Now this server ran Web server and DB server, if coupled with DNS, do not know if this 2U guy can top live, so I simply did not install DNS services, our company's DNS resolution to IDC to do, although save a server, but trouble also came, Companies often want to do two domain names (such as our company's domain name is www.ourdomain.com, often need to open similar forum.ourdomain.com such as the two-level domain name) but every time and IDC negotiations, it really makes me very embarrassed (sometimes IDC sales staff still want 50 RMB A Level two domain name). So finally I did a small program to resolve our level two domain name.

The principle of parsing is this: ServerVariables ("Http_host") this variable can return the user's requested address (for example, www.ourdomain.com or Forum.ourdomain.com, may also be your IP address) and then we can use this as a basis for parsing! The following are the resolved applet:

Redirect.asp:

<%

' First get the address that the user requested

Requireurl = Request. ServerVariables ("Http_host")

' Then redirect according to the user's requested address

Select Case Requireurl

Case "cad.ourdomain.com" Response.Redirect "http://www.ourdomain.com/cad/"

Case "forum.ourdomain.com" Response.Redirect "http://www.ourdomain.com/forum/"

' If all other requests are transferred to the company's WWW domain (you can also set it to reject other requests)

Case Else Response.Redirect "http://www.ourdomain.com/index.asp"

End Select

%>

OK, here's how to change the order of the default documents for IIS to redirect.asp/index.asp so that users can visit your site first and then go to your desired address!

On redirect processing, if you feel redirect wasting resources, you can use script instead:

<script language= "JavaScript" >

location=http://www.ourdomain.com/cad/

</script>

What do you think?

If you can not trouble IDC, you can do it!

Finally, need to point out, need IDC do DNS time to help you do all the ourdomain.com domain name resolution-all ourdomain.com under the domain name are resolved to your server

If you have any questions you don't understand, you can discuss cpplus@163.com with me.

If there are any mistakes or flaws, please do not hesitate to point out!



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.