Do you want to have your website automatically redirect to another site or specific page? (read on)

So What Exactly Do I Need to Do To Correctly Redirect My Site??
Below are snippets of code (by script/file type) to place at the very top of your homepage: (These snippets are for those who are not using content management systems like WordPress. Most likely you’ll need to implement the redirect via .htaccess, either manually or via cPanel)
PHP Redirect
<?php
header( “HTTP/1.1 301 Moved Permanently” );
header( “location: https://www.thenewsite.com” );
?>
.NET Redirect
<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”https://www.thenewsite.com”);
}
</script>
Ruby on Rails Redirect
def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “https://www.thenewsite.com”
end
ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”https://www.thenewsite.com”
%>
JSP Redirect
<%
response.setStatus(301);
response.setHeader( “Location”, “https://www.thenewsite.com” );
response.setHeader( “Connection”, “close” );
%>
PERL / CGI Redirect
$q = new CGI;
print $q->redirect(“https://www.thenewsite.com”);
.htaccess Redirect
You can also do an .htaccess redirect (copy and paste the code below into a new file as save as “.htaccess”) This single file, uploaded to the root directory of your website will redirect all directories and page files from your existing domain to the new domain.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://www.thenewsite.com/$1 [R=301,L]
*Notes:
Replace the “www.thenewsite.com” in the above code with your actual domain name.
This works ONLY on Linux servers with the Apache Mod-Rewrite moduled enabled. (talk to your webhost to verify)
Plain HTML
*If for whatever reason (as a last resort) you can only redirect a flat html page, please do the folowing “Meta Refresh” (I mention this because Google doesn’t really like it) ;)
<html>
<head>
<meta http-equiv=”refresh” content=”0;URL=https://whatever.com”>
</head>
<body>
Create Redirects via Cpanel
(video courtesy of LearningCPanel)
[…] and I see folks getting virtually punished for not knowing about nor implementing this “redirect” […]