My friend's website, whose original domain name is sitea.com, is now changed to siteb.com. Of course, sitea.com has not expired yet. It may take a while. I read this article online.
How does an SEO website achieve 301 redirection? Http://smt.fortuneage.com/uemarketer/18655-155226.aspx
It means how to implement it in Asp.net. Previously, extensive domain names were implemented using urlrewriter. I checked some Nhibernate stuff a few days ago. Some friends also used httpmodules to create a session connection for each request and release the session after the request ends.
Yes, Microsoft provides something similar to the pipe chain, and one by one modules handles it. Of course, this method can also be used to determine that only authenticated users can download files with the corresponding extension, that is, they can be intercepted and processed before being handed over to the final result.
Of course, you can create a new class on your own and inherit from the public class goxuehttpmodule: ihttpmodule
Public class goxuehttpmodule: ihttpmodule
{
/// <Summary>
/// Constructor
/// </Summary>
Public goxuehttpmodule ()
{
}
# Region ihttpmodule Member
/// <Summary>
/// Release
/// </Summary>
Public void dispose ()
{
}
/// <Summary>
/// Initialization
/// </Summary>
/// <Param name = "context"> HTTP application </param>
Public void Init (httpapplication context)
{
Context. beginrequest + = new eventhandler (context_beginrequest );
// When the page is closed
// Context. endrequest + = new eventhandler (context_endrequest );
}
# Endregion
/// <Summary>
/// Start the request
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void context_beginrequest (Object sender, eventargs E)
{
String url = httpcontext. Current. Request. url. tostring ();
If (URL. Contains ("sitea.com "))
{
String url2 = URL. Replace ("sitea.com", "siteb.com ");
Httpcontext. Current. response. Status = "301 moved permanently ";
Httpcontext. Current. response. addheader ("location", url2 );
Httpcontext. Current. response. End ();
}
Else
{
Httpcontext. Current. response. Redirect (URL );
}
}
/// <Summary>
/// End the request
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Private void context_endrequest (Object sender, eventargs E)
{
}
}
Of course, the red above can be directly written in urlrewriter. modulerewriter, which not only implements the second-level domain name, but also implements the domain name change.
At the same time, the old access method can remain unchanged. The old search engine address will also be displayed with the new domain name URL.