A 301 redirect is an essential when setting up a new webpage or migrating a website to indicate that what you’re looking for – is no longer available – and has permanently moved to a new location. But what if your 301 moved permanently status codes isn’t working as intended or is bringing up the wrong resource? This type of website maintenance is essential in making sure your website is healthy, we will explain the common types of redirect issues and errors and how to fix them.
What is a 301 Moved Permanently Redirect?
Each time you visit a website, there is a request sent from your browser to a website’s server. The web server receives this request, processes it, and sends along an HTTP header and HTTP status code. This HTTP status code normally will not be seen by someone visiting the website unless there is an error. If a server responds with an HTTP status code message, that is its way of communicating that there is some sort of an error. Within each type of HTTP status code, there is a category type that can be identified by a number that relates to the reason as to why the error occurred.
In the case of a 301 redirect, this type of HTTP status code occurs when there was supposed to be a redirection of a request to a new URL link. This HTTP status code falls under the 3xx category of response codes, all of which are redirection-related requests.
In the case of the 301 redirect, the problem occurs when there is an issue communicating a redirection request from an old to a new permanent URL link on a website. This type of error can occur when updates or changes are made to a website, but the server response redirecting the user to the new URL link has failed.
Why Do 301 Moved Permanently Occur?
Since the 3xx category of HTTP status codes are considered redirection messages, this indicates that additional action is necessary to access the website. Unlike 5xx HTTP status codes that relate to communication issues between two servers, the 301 moved permanently error occurs from an issue from the inbound website’s URL linking, and not the client trying to access it. While most browsers will automatically detect a 301 moved permanently response code and process a redirection request immediately, if the URL is not linked properly, a 301 error message will appear. Some other reasons 301 errors occur include:
- New creation of a website
- New webpage was created
- Broken URL links
- Fixing a webpage and want it to redirect to another page
How Can 301 Errors Damage a Website’s Reputation?
301 errors can impact a brand’s reputation in two ways — through search engine rankings and user experience. If your website has redirect request errors, search engines will not properly index it, and therefore decrease search rankings from an inability to detect page content. 301 errors also cause frustration for visitors as they are unable to find important content on specific pages of a website.
How do you fix a 301 error message?
1. Check Your Htaccess Files for Errors in URL Linking
Most websites run on one of these two types of popular server software — Apache. Within these server applications you will then look into the htaccess file within the root directory of your website files, as this will help determine where any redirection instructions are located.
What is an Htacess File?
Htacess stands for hypertext access, and is a type of server configuration file. Each file contains configuration directives towards a server within a directory. In simpler terms, each htaccess file basically gives instructions to a server, which could include passcode requirements for certain areas of a directory, as well as configuration to automatic redirects on certain areas of a website. If you need to update an htaccess file, it is important to ensure the file is properly titled ‘.htaccess’ only.
In order to locate the htaccess file in Apache, you can click on the username of your account associated with your server hosting. Once you have located the htaccess file within your directory, you can open it in a text editor and locate the lines Rewrite directives, which will allow you to modify these to ensure there are matching URL links for any redirects within your website.
There are two types of Rewrite directives that can be modified:
RewriteCond
RewriteRule
You will want to go through both of these within the htaccess file to make sure there aren’t any redirects to URLs that no longer exist. If there is, you can temporarily remove them and restart your website server to see if that resolves the issue.
If your server runs on nginx, your rewrite directives are identified as return or rewrite directives as opposed to RewriteCond and RewriteRule.
2. Use a Third Party Tool to Check for Any 301 Redirects
The free tools below are a great way to run a quick website audit and give some insights on any 301 moved permanently errors that might need to be modified.
https://www.redirect-checker.org/
https://sitechecker.pro/redirect-checker/
3. Backup Your Website
Before trying to diagnose any website related server issues, a first recommendation would be to perform a full backup of your website database before attempting any of the steps below. This will ensure that no data loss will occur when trying to resolve a 301 Moved Permanently Error.
4. Check Your Server Logs
Checking your server log will allow you to better understand a server’s current status. The server logs can help indicate any specific files that might be causing 301 error messages, allowing you to easily catch and adjust these files manually.
5. Check Your Sitemap
Search engines use your sitemap to crawl a website so it is important to make sure there are no 301 errors embedded into your URLs. If you have any 301 status codes for nonexistent pages, you will want to make sure these are removed. This can be done by:
- Accessing your website’s sitemap
- Download a full list of your URLS
- Filter for any 301 status codes within the list
- Delete the 301 status codes and replace them with the correct URL update
6. Check Any Custom Code Files
If you have any custom code embedded into your website with errors, it may cause redirect issues. The easiest way to test this is to remove the line of custom code and refresh the page to see if the error message goes away to understand if this was the root of the problem.
7. Change any HTTP Response Codes to 200 If You Do Not Want A Redirect
Once you have identified the 301 redirects on your website, you can alter any unintentional redirects by changing the response code to the 200 category.
8. Remove Any Redirect Chains or Loops
A redirect chain occurs when there is more than one redirect between two URL links. First identify if any of these chains exist, then replace them with a direct link to the final URL.
A redirect loop is a communication error that occurs when one URL redirects back to another URL within that chain, causing a 301 error. You will want to check your URL list for any 301 redirects to understand if any of these loops or chains exist within your website.
9. Fix Any Broken Redirects
Broken redirects occur when a URL links to a page that no longer exists. You can identify broken redirects using the same steps mentioned above:
- Access your website sitemap
- Download a list of your URLS
- Filter the list for any 301 status codes
- Bring back the pages that no longer exist or update the URL to reflect the correct page it should be redirected to
Since both search engines and visitors use 301 redirects as a way to identify a new page destination, it is important that these links are updated properly to reflect the appropriate URL where they should be linked. These error messages can negatively impact both search engine rankings and user experience if unnoticed.