What is a 301 Redirect?
What’s a 301 Redirect? You may have heard your developer talking about “301 Redirect” or “301 Moved Permanently” at your last site update/launch. What were they on about? And why does it matter?
At its simplest, a 301 Redirect or 301 Moved Permanently is a search engine-friendly tool that diverts a user request from one web location to another. The redirect happens server-side and is almost invisible – for example when you type in our full URL into your browser address bar www.little-fire.com and hit return:
The server will redirect you to our preferred domain – little-fire.com. There’s no delay (to speak of) – it’s just the URL changes in the address bar.
Why? Well, there are a lot of reasons but we chose to use the shorter URL as it is easier to type in. When it appears in print, it is easier to make the short URL larger and easier to read. But we don’t want to lose all those people adding the “www.” so we bring them to the preferred domain without interrupting their experience.
Whether you work in SEO or web development, the 301 Redirect is a essential part of your tool kit.
Definition of a 301 Redirect
301 is a status code sent to a web browser or search engine to indicate that a page has permanently moved to a new location.
Hang On! What’s a Status Code?
In short, when you call a website in your browser or app, along with whatever data the web server the data sends back, the server sends a Status Code. The code tells you the outcome of the request. This status code is an essential part of HTTP (Hypertext Transfer Protocol), the foundation of data communication for the World Wide Web.
Amongst the most common Status Codes are:
- 200 OK – Standard response for successful HTTP requests. This is the one you want, it just means everything happened as it should.
- 401 Unauthorized – if you enter your password incorrectly or try to access content forbidden to you, a well built website will return this header and show you either a login page or an appropriate warning.
- 404 Not Found – The requested resource could not be found. If the web page you asked for does not exist, a 404 status will be returned and the “page not found” warning displayed. We have seen empty product categories return a 404 code too.
- 500 Internal Server Error – A generic error message, given when an unexpected condition was encountered and no more specific message is suitable. It’s a problem on the web server. You haven’t done anything wrong.
There is even:
- 418 I’m a teapot – but that’s just geeks for you.
And code we’re looking at here is:
- 301 Moved Permanently This and all future requests should be directed to the given URL.
So Why Use a 301 Redirect? Common Use Cases
The uses of a 301 Redirect are manifold, primarily focusing on preserving the user experience and SEO strength. Here are some common reasons for its implementation:
Moving Websites & Changing Domains
Say a company gets bought out, or becomes a .com but the content needs to remain available to existing users. A developer can set up some code like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?olddomain\.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L,QSA]
Code language: JavaScript (javascript)
To redirect all content from one domain to another while retaining the URL path and query string, you can use the above code snippet in your .htaccess
file on the source domain. This .htaccess
should be placed in the root directory of your source domain’s hosting.
Here’s what each line does:
RewriteEngine On
– This line enables the rewriting capabilities of Apache.RewriteCond %{HTTP_HOST} ^(?:www\.)?olddomain\.com$ [NC]
– This line checks if the host (domain name) being accessed matchesolddomain.com
orwww.olddomain.com
. The[NC]
flag makes this comparison case-insensitive.RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L,QSA]
– This rule redirects all requests to the new domain (newdomain.com
) while retaining the URI path and query string.^(.*)$
captures the entire request URI after the domain name.http://www.newdomain.com/$1
redirects to the new domain while appending the captured request URI.[R=301,L,QSA]
flags explained:R=301
specifies that the redirection should be a “permanent redirect” (HTTP 301 status). This is useful for SEO purposes, indicating that the old page has permanently moved to the new URL.L
denotes that this should be the last rule processed if this rule is matched.QSA
means “Query String Append,” which preserves the existing query parameters on the URL.
This code assumes that you are working with Apache and have mod_rewrite enabled, which is common in many hosting environments.
Once implemented, when users type in www.olddomain.co.uk/specifications/vital-info.html, they will be seamlessly presented with www.newdomain.com/specifications/vital-info.html. This provides users with an unbroken experience whilst giving the company the opportunity to maintain just one website (the new one).
Website Updates & Platform Changes
When updating a website URLs often have to change. For example, when moving a site to Shopify, the URL pattern is very fixed. For example, on a current project, URLs for categories follow the following pattern:
https://www.example.com/shop/accessories/widgets
Code language: JavaScript (javascript)
Shopify requires that the new URL look something like:
https://www.example.com/collections/accessories-widgets
Code language: JavaScript (javascript)
The client has a long trading history and does not want to lose any existing traffic to the older URL. A 301 will mean Google will recognise the change and retain the existing ranking. In time, Google will update its indexes and store the new URL. But the old URL may still be out there in people’s old browser favourites, old emails and blog posts. 301s have a way of hanging around.
Canonicalisation
Content available via multiple URLs can dilute search engine rankings. 301 Redirects can solve this by redirecting all variations of a URL to a single, canonical version.
Secure Protocol Shifts
A few years ago, when almost all sites moved from HTTP to HTTPS, developers used 301 Redirects to ensure that users accessing the old URLs navigate to the secure protocol.
Impact on SEO
A 301 Redirect is particularly significant in the context of SEO for several reasons:
- Preservation of Rankings: By indicating the permanence of a move, a 301 Redirect helps preserve the search engine rankings accumulated by the original page. Search engines transfer the rankings of the old page to the new URL.
- Link Equity Conservation: This type of redirect also helps conserve link equity (the value passed through hyperlinks), ensuring that the SEO benefits from external links pointing to the original URL are not lost.
- Avoiding Duplicate Content Issues: It helps avoid penalties associated with duplicate content by directing all visitors to one authoritative page, thereby streamlining content in the eyes of search engines.
How to Implement a 301 Redirect
Implementing 301 Moved Permanently varies depending on the server and the website management platform in use. But it is almost always a developer-level job. There are WordPress plugins to configure them but they are very much at technical end.
In general, redirects can be set up through server configuration files (like .htaccess on Apache servers), plugins or extensions for content management systems (CMS), or via code in server-side languages like PHP.
Potential Drawbacks
While beneficial, 301 Moved Permanently should be used with care. Improper use can lead to issues such as:
- Redirection Loops: Incorrect setup can create infinite loops, where redirects lead back to themselves, potentially causing the site to become inaccessible.
- Performance Delays: Each redirect introduces a slight delay in page loading times. Excessive redirects can significantly impact site performance and user experience.
- Temporary Ranking Drops: Initially, there might be a slight dip in rankings as search engines adjust to the new URLs.
- Broken Forms: When a page is redirected, much of the data sent with the original request is lost. For example, if you submit a form, and a 301 takes place in the transaction, the information you put into that form will be lost. Your developer needs to fix this.
Although the 301 works well and smoothly, relying on them for internal links is considered poor SEO practice. If you have updated your website and have pages that rely on them to make it work. It is worth taking some time to update the links to the new URL site-wide. It’s not an urgent job, but it is important.
Conclusion
A 301 Redirect is a powerful tool in the web developer’s arsenal, essential for maintaining user experience and SEO when URLs are changed. Proper implementation ensures that visitors and search engines are directed to the correct pages, preserving the integrity and effectiveness of a website’s navigational structure. When used correctly, it seamlessly bridges the gap between old and new content, which is vital for both site operators and their audiences.