Ways To Setup 301 Permanent Redirect On Your Website

Small SEO Optimizatation Tools

Ways To Setup 301 Permanent Redirect On Your Website

06/12/2016 12:00 AM by Admin in Seo, 301 redirect, wordpress

Redirect means to “forward one web page to another” and it is mostly used for expired pages and event pages. For example, you are going to hold an event on your website in February 2016 and after February the event will end and the event URL expire.  There are several types of redirect and “301 Permanent Redirect” is one of the most professional and search engine friendly for websites redirections.  

                                                       Setup 301 redirect on your website from SmallSEOTools


What is 301 Redirect?


“301 redirect” is a permanent redirection way to forward your website visitors from “www to non-www” and “now-www to www” extension. It is a very important way to optimize your website to become it search friendly. You just need to edit your .htaccess file to optimize your website. It is very necessary to define about your domain to search engines using 301 redirection codes.


How to avoid duplicate content issues using 301 redirect or .htaccess file?


The domains without 301 redirection configuration have to face the issue of a duplicate content issue because the search engines consider the page with www and non-www two different page, so it creates a duplicate content issue and the result in the drop of website ranking. Search engines are very fast in this age, and mainly the Google is very quick to take action against a duplicate content issue and drop the ranking within few days and don’t store it easily.


Example: let suppose that, your website is www.yourdomain.com and if you have not yet configured the 301 redirect the Google will automatically index and both URL with www and non-www e.g. yourdomain.com and www.yourdomain.com and consider it two different pages. So, it will create the duplicate content issue for your website.


Is professional web developer needs to use 301 redirects?


No, it is not necessary that you must be a professional web developer to fix 301 error. You just need to log in your Webhosting Cpanel and edit the .htaccess file and add some coding under “Rewrite Engine On”. So, you need to have some basics about the Cpanel, web hosting and website admin panel to use redirects feature.

The 301 redirection is one of the most powerful and search engine friendly ways to redirects your WebPages permanently. You can use 301 permanent redirects if you are suffering from the several situations including:


  • To redirect old WebPages to new URL.

  • To change the structure of URL

  • To prefer one version of website (With www or without www)

  • Setup various domain to your website


There are some situation above mentioned or other which can be the reason to set up 301 Redirect, blow I am going to share simple ways to set up 301 custom redirects and these are commonly used. There are several types of redirections but here I discuss a few one listed blow.


  1. Php Single page redirect

  2. PHP Canonical redirect

  3. Apache .htaccess single page redirect

  4. Apache. Htacess Canonical redirect

  5. ASP single page redirect

  6. ASP Canonical redirect


How to setup PHP single page redirect?


If you want to setup PHP single page redirect to forward the static page to fresh address you just insert the blow given PHP code in Index.php file and save.


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


Updating above code in index.php will redirect your existing domain to new permanently and it is the way to promote your website for fast ranking. It means your redirect all of the users of one niche to another one.


1. How to setup PHP canonical redirect?

This is one of the most important SEO factors to setup canonical redirect and you can read more about the canonical redirect on the SEOMoz. It will basically add or remove the prefix “www” to all of your web pages. The blow given code will redirect the visitors of non-www http://youdomain.com to www version http://www.yourdomain.com


if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$_SERVER['HTTP_HOST']


2. How to Setup Apache .htaccess Single Page Redirect?

This method can be used for the redirection of single web page of your website to new one and you can update it using .htaccess. First of all copy the blow given code and log in to your website root directory to edit .htaccess file to insert the code. And update the domain.com with your domain address. Save the .htaccess file to for changes.


Redirect 301 /old/oldpage.htm /new/http://www.domain.com/newpage.htm


3. How to setup Apache .htaccess canonical redirect on WordPress and custom CMS?

It is vastly used way to update canonical redirect and me also using this one. You need to insert the blow given code into your website .htaccess file right after the RewritingEngine On in your website root directory. It will redirect your visitors to your preferred version of the website (www or non-www). And don’t forget to update domain.com to your personal domain. These setting can be used for WordPress and custom based cms websites.


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


4. How to Setup ASP Single Page Redirect?

This way is only for special cases, I mean it is mostly used for active server pages platform. It can be performed to forward previous server pages to new URL.


Response.Status="301 Moved Permanently"


5. How to setup ASP Canonical Redirect?

It can be widely used to setup ASP canonical redirection and it is an advanced feature. In this, the ASP must have to be located in the script which is executed on server’s every page before the page contents begin. You need to have some technical knowledge to manage server to use this way.


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


Final Arguments: I explained all about the 301 error in simple and easy with depth and I hope it will clear all of your question and issues about the web redirection. If you’re facing any issue about to update the redirection then share it.

leave a comment
Please post your comments here.

Popular SEO Tools