Redirect URL using 301 redirection for affiliate Marketing
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", NEW_URL);
}
Method 2.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string sOldPath = HttpContext.Current.Request.Path.ToLower();
string sPage = "http://www.aspcode.net/articles/" + sOldPath;
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location",sPage);
Response.End();
}
Method 3.
protected override void OnInit(EventArgs e)
{
int i = Request.Url.ToString().IndexOf("www.");
if (i < 8 && i != -1)
{
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", Request.Url.ToString().Remove(i, 4));
Response.End();
}
base.OnInit (e);
}
No comments:
Post a Comment