Add To Favorites | St George Blog
Sales: 888.55.WEBSITE ext. 1
Support: 888.55.WEBSITE ext. 2

Code Redirect

Single File HTML Redirect

Redirect 301 /olddirectory/oldfile.html http://yoursite.com/newdirectory/newfile.html

Apache Directory Redirect

RewriteEngine On
RewriteRule ^olddir/(.*)$ http://domain.com/newdir/$1 [R=301,L]

Redirect Error 400s

ErrorDocument 401 /401page.html
ErrorDocument 403 /403page.html
ErrorDocument 404 /404page.html
		

Redirecting in Java

<%
	response.setStatus(301);
	response.setHeader( "Location", "http://www.new-url.com/" );
	response.setHeader( "Connection", "close" );
%>

Redirects for ASP .NET

<script runat="server">
	private void Page_Load(object sender, System.EventArgs e)
	{
		Response.Status = "301 Moved Permanently";
		Response.AddHeader("Location","http://www.new-url.com");
	}
</script>

ASP Redirects

<%@ Language=VBScript %>
<%
	Response.Status="301 Moved Permanently";
	Response.AddHeader("Location","http://www.new-url.com/");
%>

Single File Redirect in PHP

<?php
	Header( "HTTP/1.1 301 Moved Permanently" );
	Header( "Location: http://www.new-url.com" );
?>

Redirecting for Cold-Fusion

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">

IIS Redirecting

In internet Services Manager, right click on the file or folder you wish to redirect. Select the radio button called "a redirection to a URL". Enter the redirection page. Check "The exact url entered above" and the "A permanent redirection for this resource". Then Click on 'Apply' and that should do it.

Using CGI Perl to Redirect

$q = new CGI;
print $q->redirect("http://www.new-url.com/");

Redirecting to a New Domain using mod_rewrite

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Redirect no www to www

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]

*This will ensure that all requests coming in to domain.com will get redirected to www.domain.com