For Linux / Unix:

This will likely be done in the vhosts container (/etc/httpd/conf/vhosts.conf), although yours may be different.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

Make sure to escape periods in the RewriteCond line with backslashes. Reasons you might wish to do this mostly relate to search-engine friendliness and unity of web stats.

Windows:(IIS5 /IIS6/II7)

This will be done in IIS (Internet Information Server). Goto the website in question that you wish to redirect and right click on it. Click properties and then goto home directory. Here you will check “a direction to a url” and then enter the url you wish to redirect to. Also make sure you check “A permanent redirection for this recourse”

.301redirect.gif

You also can do coding redirects, that you would add to your landing / main page on your website.

ColdFusion Redirect

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

PHP Redirect

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

ASP Redirect

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

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.new-url.com”);
}
</script>

JSP (Java) Redirect

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

CGI PERL Redirect

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

Ruby on Rails Redirect

def old_action
headers["Status"] = “301 Moved Permanently”
redirect_to “http://www.new-url.com/”
end

Leave a Reply