. NET IIS domain name Pan-resolution combat

Source: Internet
Author: User
Tags base64

Recently do a personal website want to achieve a number of two-level domain names, one to remember, and secondly for the search engine optimization, search engine for the two-level domain name collection or relatively fast. Just started to do 4, 5 two domain name, each is in the domain name resolution manually added, but with more than two domain name more and more, found this way too troublesome too tired, so just want to through the program to achieve a number of two-level domain name resolution.

To achieve a two-level domain name Pan-resolution, the first to add a pan-resolution in the Domain name Management Add a record host record written * can be,

Next we need to build a website on IIS such as called Fanjiexi Host header to leave the default page set to the page we want to use fanjiexi.aspx, such as

At this point we are ready to configure the work, the following can write a program to achieve an unlimited two-level domain name.

For example, my site 51tools.info is mainly a variety of online tools, each tool I have built a two-level domain name, so there will be many two-level domain name, and the number of wexin.51tools.info inside the collection of public number of articles, each public number is a two-level domain name, you can imagine how many two-level domain name

Now let's see how the program is implemented.

We set up a file under our project called Fanjiexi.aspx we know that the website we built above already has the default page already, and we have set up pan-resolution to this site, that is, any level two domain name will visit this page, So we just need to intercept the output of our two-level domain name to show the results.

The key code is as follows

         varURL =Request.Url.Host; StringWriter Output=NewStringWriter (); if(URL.) Contains ("Ip.51tools.info"))            {                if(request.querystring.count>0) {HttpContext.Current.Server.Execute ("/ip.aspx?"+request.querystring, Output); }                Else{HttpContext.Current.Server.Execute ("/ip.aspx?ip="+Common.MyRequest.GetIP (), output); }            }            Else if(URL.) Contains ("Base64.51tools.info") {HttpContext.Current.Server.Execute ("/base64.aspx", output); }
Response.Write (output. ToString ());

The code is very simple, we are to get the user access to the domain name, and then go to call our own real page output results, so the user sees is a complete two level domain name. With database queries we can also easily implement the above-mentioned public number two domain name. In this way we manage very well, we only need to maintain our real page.

Article Source: http://www.cnblogs.com/weiguang3100/

Online tool: Http://51tools.info

. NET Development Communication

The copyright of this article is owned by the author and the blog Park, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to give the original link.

. NET IIS domain name Pan-resolution combat

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.