How to Set Up a Redirect

Setting Up a 301 Redirect

A 301 Redirect is useful when you need to permanently redirect traffic from an out of date or deleted URL to a new URL.

The 301 Redirect is very simple to set up and just requires a line of code be added in the .htaccess file for the site. 

The easiest way to do this is from within your web host’s Cpanel interface which includes a Redirects function that takes care of all this for you.


Setting Up a PHP Redirect

To implement a neater link for an ugly url is also pretty simple and is often best achieved using a PHP Redirect.

Use your website file manager (such as File Manager in cPanel for many web hosts), or FileZilla FTP manager and create a new folder at the root level of the site.

The folder should be the name that you want visitors to see at the end of your websitename.

For example, create a folder called Gizmos.

In that folder create a file called index.php

We’d use the following code for the content of that file:

php redirect code

Now use the link wherever you want the affiliate link to appear on your site (i.e. instead of the ugly affiliate link)

When visitors click on it, they will be redirected to the merchants site using your affiliate link code.


You can take this a step further and use a technique called a Link Hub to implement and manage several such redirects.

This involves using a dedicated domain name to use as the link hub.

You then create a folder for each redirect you want to implement:


In each folder create an index.php file as above, replacing the affiliate link with the appropriate one for the BlueGizmo link, RedGizmo link, GreenGizmo link etc…

Then wherever you want a link to appear for Red Gizmos, you just use instead of the normal affiliate link.


This technique has the advantage that if you change the merchant you are affiliated to, you can just change the redirect code in the appropriate index.php file to point to the new merchant using the new affiliate link they give you.

If you have many such links scattered around your site, or even over several sites, then they effectively all get updated to point to the new merchant when you edit just the one line of code in the index.php file.


Using a Redirect Hub

If you want to implement a lot of redirects (perhaps you have several sites), it can make sense to purchase a domain to be used purely as a central place to manage them.

This very site uses a redirect link hub for many of its links. Hover over one in the “Products” or “Services” pages and you’ll likely see  be displayed.

This means all the external links throughout this site can be easily managed from one location. If any links need to be updated one simple change will effectively make them all current again, redirecting the visitor somewhere useful instead of to an out of date or dead page.


About David

Leave A Comment...