780-800-2328 Menu

How to Properly Use 301 Redirects

Over the course of my life, I have had multiple residences around the world, and each time I moved I would walk over to my local post office and sign up for mail forwarding.

Mail forwarding is a process which ensures that you do not lose valuable letters or parcels that have been sent to you. Similarly, in the digital world, you are able to setup domain or web page redirects. These redirects automatically send visitors and inform search engines that content for this request has been moved permanently or temporarily without disturbing the flow of traffic, or valuable link juice.

What is a 301 redirect?

A 301 redirect indicates that content for this page has been permanently moved to another address. It also notifies search engines and various indexing tools appropriately to maintain the ranking power of the URL during the transfer.

How to implement a redirect?

Redirects can be implemented using either a server-side or client-side framework. Server-side frameworks utilize HTTP status codes and transfer them to user agents (browsers or crawlers). Client-side redirects, however, may or may not use them as they are carried without a response directive sent to the user agent. This may lead to inconveniences such as the user not being forwarded appropriately, making server-side redirects the preferred option.

.htaccess redirect

In most cases, server-side redirects are carried out via .htaccess, a configuration file located in the root folder of the domain’s public directory. This file can also be edited to overwrite server configuration or make use of various modules loaded via Apache on the web server, key of them being the mod_rewrite module. Following is an example using the redirect directive:

Redirect 301 /example-document.html http://www.example.com/example.html

The above line of code begins with the directive and the HTTP status code to be used in the response to a matching request. In this case, the server will ‘redirect’ as a ‘301’ all traffic to the URL ‘/example-document.html’ to the destination URL ‘http://www.example.com/example.html’.

Alternatively, a redirect can also be written using the apache module mod_rewrite:

RewriteEngine On
RewriteRule ^/example-document.html$ http://www.example.com/example.html [L,R=301]

Here, the first step is to activate the Apache webserver’s mod_rewrite module with the command ‘RewriteEngine On’. After which a rule is added to match incoming requests and the destination URL followed by the directive and response code in square brackets. Rewrite rules also support the use of regular expressions, allowing developers to implement multiple redirects using a single line.

Note: Since changes implemented in a .htaccess file are immediate, they should be thoroughly tested as a single illegal character could result in internal server errors and a response code of 500 affecting website operations for all users.

Do you have any primo tips for 301s? Have you ever run into a huge problem with 301s on your site? Let us know or reach out to our team for support!