Redirecting with a 301 redirect
For many reasons, including search engine optimisation, it is important to add 301 redirects for any old pages on your site which no longer exist. There are many ways that you can do this, dependent on the hosting platform that your site operates from, as well as your own preference on what you are comfortable using. There are a few examples below which will allow you to create 301 redirects no matter which platform you are working from.Example for Apache and .htaccess
RedirectMatch 301 (.*)\.htm$ http://www.example.com$1.php
Example for Zeus and rewrite.script
insensitive match URL into $ with ^/(.*)\.htm(l)? if matched then set OUT:Location = http://www.example.com/$1.php set RESPONSE=301 set BODY=$1 goto END endif
Example for PHP Redirect
<? Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://www.new-url.com" ); ?>
Example for ASP Redirect
<%@ Language=VBScript %> <% Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.example.com/" %>
Example for ASP.NET Redirect
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com");
}
</script>
