301 Redirects And Canonical Urls

Hello Friends

At the time you move a document on your server you need to be sure that you pass the best possible redirect directive to the programs and all the more essentially, the Search Engines. The 301 redirect is the main redirect we propose for anybody to use without progressed learning of utilizing redirects. 302 redirects are really utilized by Seo's for some particular explanations, for example moving area names from an old domain.com to another domain.com

301 Redirects & Canonical Redirects for Apache 

This is finished on the imperceptible document named ".htaccess" this index is spotted in the base of your Web Server.

For a solitary page redirect (Never utilize a 302 determine it says either "Permanent" or "301" in the document assuming that it doesn't it will pass a 302 by default:

redirect 301 /old-file-name-html http://www.yourdomain.com/new-file.html
redirect permanent /old-file.html http://www.yourdomain.com/new-file.html

Notice all that is wanted is one space between the old way and the new Url. The new Url must hold an Absolute Url: importance it utilizes http://www.yourdomain.com/yourfile.html. Provided that there is a space in the document name use %20 any other way it won't work, you can just abandon one space and that is between the old document way and the new url. Here is an illustration: 
/old%20file.html http://www.yourdomain.com/new-file.html

Apache Server Canonical Redirect 

(non-www to www): 

This might as well dependably be finished as some web indexes don't legitimately comprehend the contrast and might consider it a copy page, furthermore provided that you utilize domain.com/index.html or domain.com/index.php the Search Engine may get lost. Since Google is the most notorious Search Engine, it likewise happens to be a touch age-old in its taking care of authoritative issues and redirects. What Google will see as the same page copied on your site in all actuality its all the same page). 


Since Google supports punishments over relative substance you have to verify you Never connection to your home page as "index.html" or whatever available record augmentation. The robotized components of the Google calculation might harm your rankings without cautioning accepting that you have a higher potential of spam from double content. Google for the most part does not tell webmasters of punishments, so you could be using years attempting to determination an issue such as this. Make all your connections Absolute (Full Url) regardless to your home page, so any connection on your site may as well dependably connection to "http://www.yourdomain.com/" make certain to utilize the trailing slice as a few servers will pass a redirect to the trailing slice in the event that you don't, and this will be a 302 redirect. This is a known issue on Webstar Server, an old Mac Platform web serverthat has no redirect proficiencies. 


<a href="http://www.yourdomain.com/">
<a href="http://www.yourdomain.com/index.html"> -Not direct to the domain.
<a href="http://www.yourdomain.com"> - No Trailing Slash
Now for the .htaccess canonical redirect for the NON-www. to the www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

Note: Some Versions of Apace require an added line or two of code for Symlinks and an alternate structure of the revise control as takes after: 

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
A More advanced version will even allow you to 301 your IP address and any subdomains:
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

The above code will 301 your non-www to your www, as well as redirect your IP address as a 301 to your www.

For IP Redirection Use:

RewriteCond %{HTTP_HOST} ^12\.34\.567\.890
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
To redirect your http pages but NOT your https pages use:
Say for instance, your secure certificate was not created as www.domain.com, but was instead issued as domain.com then you would need to use the following and be sure to combine this with ABSOLUTE links (absolute links use the full URL), or you may unintentionally cause duplicate https and http paths.
RewriteCond %{SERVER_PORT} ^80
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L,QSA]
301 Redirects & Canonical Redirects: 

Microsoft IIs Web Servers 

To Perform this you need managerial access to the Iis Server Application. In the event that you don't have this then you can do the redirects in Asp or Php. 

Single Page Redirect: 

1. open Internet Services Manager then "right-click" on the record or organizer you need to redirect to another page or envelope. 
2. select "redirection to a Url". 
3. enter the Url where you need the redirect to head off to. 
4. check the fields: "careful url entered above" and "A changeless redirection for this asset". 
5. click "Apply". 

PHP 301 Redirect 

This is added to the page that you need to redirect to another page, it is triggered on the appeal for the particular page and the record will truly give back where its due. 

Single Page Redirect: 

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.new-url.com/');
PHP Canonical Redirect:
(non-www to www)
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently'); 
header('Location: http://www.'.$_SERVER['HTTP_HOST']

Redirects & Canonical Redirects for Active Server Pages (Asp) 

Single Page Redirect: 
This is put on the page you are redirecting and is triggered when somebody tries to enter the page. 

<%@ Language=VBScript %>
Response.Status="301 moved permanently"
Response.AddHeader "Location", "http://www.domain.com/"

ASP Canonical Redirect:

(non-www to www):

This code ought to be embedded into a worldwide incorporate record or any script which is executed for each page on the site after the page yield starts. Provided that your programmers are utilizing Asp.net or they are not utilizing a worldwide index, you have to have them address this issue or perform the Canonical Redirect from the Iis Server Application (as above). 

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

301 Redirects for ASP.NET

For Single Pages:
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";

Canonical Redirect for ASP.NET (ASPX):

For Asp.net you have to do this separately in the Windows Iis Internet Services Manager or Use The Asp Code above in a worldwide record that wil methodology the redirect Before whatever available procedures. 
301 Redirects for Macromedia ColdFusion

Since Cold Fusion is ordinarily had on Windows, Linux, and Sun. The .htaccess and Windows Iis excercises above will have answers for the Canonical and redirects. This is for a Single Page Redirect implanted straight into the document: 

<cfheader statuscode="301" statustext="Moved permanently">
<cfheader name="Location" value="http://www.new-location.com/">
301 Redirects for Sun Web Servers

Keeping in mind the end goal to do this on a Sun Platform you need to change the Sun Web Server's standard activity of continually utilizing a 302 redirect to dependably utilize a 301 redirect. You need to open the obj.conf arrangement record and include the accompanying lines underneath the 
<Object name="default"> line:

<Client code="302">
Output fn="set-variable" error="301" noaction="true"

The above will make the Sun web server to give back 301 lasting redirect reactions for all redirects. Provided that you just need to utilize a 301 changeless redirect reaction for certain Urls or records, you can add accompanying to the base of obj.conf: 

<Object ppath="path">
<Client code="302">
Output fn="set-variable" error="301" noaction="true"

Popular Posts