301 Redirects

A 301 redirect tells web browsers and search engines that a web page has moved permanently to a new location. This helps preserve the old page’s traffic and ranking while directing visitors to the updated content.

In this guide, we will explain what 301 redirects are, how to use them, and why they are essential for search engine optimisation.

What is a 301 redirect?

A 301 redirect is a type of HTTP status code that indicates a permanent redirect from one URL to another. It tells search engines and web browsers that a particular webpage or resource has been permanently moved to a new location.

When a webpage is redirected using a 301 redirect, it sends a status code 301 with the new URL for redirection. This code helps search engines understand that the content has permanently moved and should be indexed under the new URL.

When to use 301 redirects?

301 redirects are commonly used when a website undergoes restructuring, changes its domain name, or when specific web pages are moved to different URLs.

What is the purpose of 301 redirects?

A 301 redirect transfers the SEO value of the original URL to the new location. It ensures that users and search engines are directed to the updated URL, avoiding broken links. This helps to maintain the website’s ranking in search engine results.

How to do a 301 redirect?

To implement a 301 redirect, you will need access to your website’s server or content management system (CMS). The specific steps may vary depending on your setup, but here are some general methods you can use:

Server Configuration

If you can access your website’s server configuration files (e.g., Apache .htaccess file), you can add redirect rules directly to the configuration. Here’s an example of how to set up a 301 redirect using Apache’s mod_rewrite module:

          RewriteEngine On
          RewriteRule ^old-url$ /new-URL [R=301,L]

In this example, when someone visits “old-URL” on your website, they will be redirected to “new-URL” with the 301 status code.

CMS Plugins

Many content management systems provide plugins or modules that allow you to easily manage redirects. If you’re using a CMS like WordPress, you can install a plugin like “Redirection” or “Simple 301 Redirects” to set up and manage redirects through a user-friendly interface.

These plugins typically offer a simple form where you can enter the old URL and the corresponding new URL, and the plugin takes care of the redirection.

Redirect via PHP or other scripting languages

If you have access to the server-side scripting of your website (e.g., PHP), you can handle redirects programmatically. Here’s an example using PHP:

          header(“HTTP/1.1 301 Moved Permanently”);
          header(“Location: http://www.example.com/new-url”);

This code snippet sends the appropriate HTTP headers to indicate a permanent redirect (301) and specifies the new URL. Place this code at the top of the file or in the proper location to execute the redirect before any other content is sent to the browser.

Redirects in WP Engine

WP Engine has deprecated the .htaccess file, so you must use other redirect methods.
One way is via the User Portal.
Log in to your account and navigate to the “Redirect Rules” section in the WP Engine dashboard.

Click New redirect rule.

In the Redirect name field, write a simple title to describe what the redirect is for. You can also leave this blank, and a number will be applied.

Click on the drop-down on the domain field and choose the specific domain to apply redirects to that domain.

In the source field, type in ^source/?$ with the source referring to whatever follows the domain of the URL you want to redirect. For example, if the URL you want to redirect is http://myoldwebsite.com/oldcontent/123, you should type in ^/oldcontent/123/?$ in the source field.

In the destination field, type in the URL path the redirect will result in.

This method is recommended for at most 1000 redirects. For more than 1000 redirects, WP Engine suggests loading redirects into the Redirection plugin or managing redirects in Yoast Premium if you’re using Yoast SEO.