301 Redirect
Have you ever wondered what a 301 Redirect is? If you have been one of those that has often wondered what it is, then feel free to read this post.
To begin with, this is a way to redirect your websites. Some of the ways that it can be used are as follows:
It can be used as a way to take an old site that you might have and point it to a new address
It can be used if you have a lot of domains that you want to point to one particular site
It can be used to display a certain version of your site
It can also be used if you want to change your URL structure.
There are a variety of ways to setup a 301 Redirect. We will list the most popular methods along with the code that can be used.
PHP Single Page Redirect
This code can be used when you want to redirect a static page to a new website address. You will want to put it into the index.php file.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/page.html");
exit();
?>
Apache .htaccess Singe Page Redirect
This code is used when you are trying to redirect from an old page with no suffix to one that has a suffix. In this method, the code must be placed in an .htaccess file.
Redirect 301 /old/oldpage.html /new/http://www.domain.com/newpage.html
Apache .htaccess Canonical Redirect
This code can be used to redirect the visitors that are looking at the domain name to the site that is showing the www.domain
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
ASP Single Page Redirect
This code is used if you are using Active Server Pages.
<%
Response.Status="301 Moved Permanently"
Response.AddHeader='Location','http://www.new-url.com/'
%>
ASP Canonical Redirect
You can use this code when using the Active Server Page platform. The code must be put into a script. This script must be run for every page on the serve before the page content begins.
<%
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("SCRIPT_NAME")
End if
%>
Have you ever wondered what a 301 Redirect is? If you have been one of those that has often wondered what it is, then feel free to read this post.
To begin with, this is a way to redirect your websites. Some of the ways that it can be used are as follows:
It can be used as a way to take an old site that you might have and point it to a new address
It can be used if you have a lot of domains that you want to point to one particular site
It can be used to display a certain version of your site
It can also be used if you want to change your URL structure.
There are a variety of ways to setup a 301 Redirect. We will list the most popular methods along with the code that can be used.
PHP Single Page Redirect
This code can be used when you want to redirect a static page to a new website address. You will want to put it into the index.php file.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/page.html");
exit();
?>
Apache .htaccess Singe Page Redirect
This code is used when you are trying to redirect from an old page with no suffix to one that has a suffix. In this method, the code must be placed in an .htaccess file.
Redirect 301 /old/oldpage.html /new/http://www.domain.com/newpage.html
Apache .htaccess Canonical Redirect
This code can be used to redirect the visitors that are looking at the domain name to the site that is showing the www.domain
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
ASP Single Page Redirect
This code is used if you are using Active Server Pages.
<%
Response.Status="301 Moved Permanently"
Response.AddHeader='Location','http://www.new-url.com/'
%>
ASP Canonical Redirect
You can use this code when using the Active Server Page platform. The code must be put into a script. This script must be run for every page on the serve before the page content begins.
<%
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("SCRIPT_NAME")
End if
%>
Post A Comment:
0 comments:
Thanks For Your Commenting