Description:
I bought a virtual host, bought multiple domain names, and set all domain names to be resolved to this virtual host, and asked different domain names to point to different home pages. What should I do?
I have not set any domain name to point to, but I know that a virtual directory can only have one default homepage, and finally I thought of an idea:
In page_load on the homepage, retrieve the URL entered by the user and obtain the domain name. Then, determine which homepage to direct to based on the domain name;
This is probably the idea, Code As follows: If ( ! Ispostback)
{
// This is a string like www.xxxx.com.
String URL = Httpcontext. Current. Request. url. Host. tostring (). tolower ();
If (URL. indexof ( " Aa.net " ) ! = - 1 )
{
Response. Redirect ( " Http://www.aa.net/Index_a.html " );
}
Else If (URL. indexof ( " Bb.net " ) ! = - 1 )
{
Response. Redirect ( " Http://www.bb.net/Index_ B .html " );
}
// Other code
/// /Obtain the URL of the current request
// Request. rawurl;
/// /Obtain the URL Information of the client's last request. The request is linked to the current URL.
/// /This can be read only after the hyperlink is obtained. The read result from redirect is null.
// Request. urlreferrer;
/// /Host part of the URL Information of the current request
// Request. url. Host;
}
}