Tsohost Help Centre

Table of Contents

Using 301 Page Redirects

Updated Apr 7th at 14:04 BST

If you renamed or moved pages of your website, a 301 redirect lets you automatically redirect visitors and search engine spiders to your new pages while maintaining your search engine ranking. For example, you can redirect traffic from oldpage.php (.asp or .jsp) to "http://www.newdomain.com/newpage.html" and retain your search engine ranking and backlinks. Use the code below to redirect traffic to your pages using a 301 Redirect.

Note: In the code examples below, replace "oldpagename" with the name of your old web page from which you want to redirect traffic and replace "newpage.html" with the name of the new web page to which you want to redirect traffic.


When using a Linux server with the Apache Mod-Rewrite module enabled, you can create a .htaccess file to ensure that all requests to coolexample.com will redirect to www.coolexample.com, where "coolexample.com" is your domain. Save the .htaccess file in your old website's root directory, which is the same directory as your index file. You can create a .htaccess file with the following code:

RewriteEngine on
rewritecond %{http_host} ^coolexample.com [nc]
rewriterule ^(.*)$ http://www.coolexample.com/$1 [r=301,nc]


Save this as oldpagename.php:

 header("HTTP/1.1  301 Moved Permanently");
 header("Location: http://www.newdomain.com/newpage.html");