CodersAdvocate

I work hard, so you don't have to

programatically raise a 301 redirect

 

Sometimes you may wish to tell users and more specifically web crawlers that a page has moved permanently. You do this by modifying the response status to a 301.

301 means Permament move.

This is how you raise such an event in C sharp (C#)

	context.Response.Clear();
	context.Response.Status = "301 Moved Permanently";
	context.Response.AddHeader("Location", url);
	context.Response.End();

This is how you raise such an event in PHP

	Header( "HTTP/1.1 301 Moved Permanently" );
	Header( "Location: http://www.newlocation.com" );
Copyright 2011 CodersAdvocate ©