![]() Professional SEO - Israel |
|
|||||||||||
A permanent redirect allows you to inform your visitors or search engines that reach your website that a certain page, folder or the entire site moved to a new address. The redirection to the new address will be automatic for site users, while the address displayed in the address bar on their browser will be updated to new URL. When you request a page in the regular manner, the server returns to the user a 200 code that states that the request was successful. In case of a permanent redirect, the server returns a 301 code and the updated URL of the requested resource. Permanent redirect is designed to perform the following actions:
The abovementioned changes require access to the site's .htaccess files. In the event the website no longer exists, or will not exist in the future, you should ask your service provider to perform the redirection at server level (through the httpd.conf file). Why is it Important to have a Permanent Redirect?In many cases site owners wish to change their website's structure, or its domain. These kind of changes may create several problems:
Testing the HTTP HeaderAfter performing a permanent redirect, you should make sure that the redirect indeed functions properly, and that you receive a 301 code when you reach the old page or domain, and not a different code (e.g.: code 302).
Redirect at Server Level vs. Redirect at Site LevelYou can perform the permanent redirect at server level (through your hosting services provider) or at site level. Advantages and disadvantages of server level redirection (httpd.conf):
Advantages and disadvantages of site level redirection (htaccess):
Permanent Redirect through the ServerFirst, the server should enable performing permanent redirections. This is done through the server's definitions file (httpd.conf), where you should define the next line:
AllowOverride All
Then, you can see a number of examples for writing permanent redirections by inserting commands to the htaccess file which you should place in the folder that contains the page that is about to change. The general structure of the command is quite simple:
Redirect status old new
Here is the first example: using the htaccess file to redirecte a folder on the old site to a new domain (splitting a folder to a new website):
Redirect permanent /folder http://www.newdomain.com/newfolder
Any redirect that will reach the "folder" folder on the old site will be redirected to the "newfolder" folder under "newdomain.com" domain. The redirect will be to the new folder, and inside it to the page name. In case you also changed the names of the pages inside the folder, some problems may occur. Here is an example of redirecting a single file to a different file (in this case - the new file is located on a different domain):
Redirect permanent /old.htm http://www.new.com/newpage.html
To conclude, a full redirect of a domain to a new domain:
Redirect permanent / http://www.newdomain.com/
Order of Commands is ImportantOrder of commands is important. The correct way to write the commands will be:
Redirect permanent /folder http://www.firstdomain.com/
Redirect permanent / http://www.seconddomain.com/ And not:
Redirect permanent / http://www.seconddomain.com/
Redirect permanent /folder http://www.firstdomain.com/ In the last example, the system will not reach the second condition. Permanent Redirect on IISA permanent redirect on IIS requires access to the hosting server definitions. In order to perform the permanent redirect on IIS, you should perform the following:
Permanent Redirect with ASPThere is an option of performing a permanent redirect with an ASP command. Following is an example for a redirect code:
if lcase(request.servervariables("HTTP_HOST")) = "domain.com" then
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "http://www.domain.co.il/" end if This code checks whether the domain that originated the call is "domain.com", and in case it is, a permanent redirection is performed to "domain.co.il". The redirection should be performed before any input to the page, meaning before the html and head tags. Permanent Redirect with PHPThere is an option of performing a permanent redirect with a PHP command. Following is an example for a redirect code:
<?php
header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.domain.co.il/"); ?> This code performs a permanent redirect to domain.co.il. The redirection should be performed before any input to the page, meaning before the html and head tags. |
||||||||||||
|
||||||||||||
|
||||||||||||
|
© 2004-2007 All rights reserved, SEO Israel Technologies Ltd. |
||||||||||||