How to setup a 301 Redirect

“301 Permanent Redirect” A ?? The website is the most efficient and search engine friendly way to redirect.
You can use it with different scenarios: a new address to redirect an old website setup several domains pointing to the website, only one version of your website (WWW. Or no-WWW) is to strengthen and harmonize a URL structure change, I will cover the most used ones The
following are several ways to set up a 301 redirect:

PHP Single Page Redirect You can redirect a static page with a new address, so that the index.php file, enter the following code inside.

PHP Canonical Redirect

The Canonical 301 Redirect will add (or remove) the www. prefixes to all the pages inside your domain. The code below redirects the visitors of the version to

Apache .htaccess Singe Page Redirect

In order to use this method you will need to create a file named .htaccess (not supported by Windows-based hosting) and place it on the root directory of your website, then just add the code below to the file.

Redirect 301 /old/oldpage.htm /new/

Apache .htaccess Canonical Redirect

Follow the same steps as before but insert the code below instead (it will redirect all the visitors accessing to

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^ [nc]
rewriterule ^(.*)$$1 [r=301,nc]

ASP Single Page Redirect

This redirect method is used with the Active Server Pages platform.

<% Response.Status="301 Moved Permanently" Response.AddHeader='Location','' %>

ASP Canonical Redirect

The Canonical Redirect with ASP must be located in a script that is executed in every page on the server before the page content starts.

<% 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 %>

(Visited 39 times, 1 visits today)