A redirect is a way to forward visitors and search engines from one URL to another. This is useful when moving content to a new URL, when deleting pages or when changing domain names or merging websites.
Whenever possible avoid using redirects, but when you have to use them, make sure to follow these best practices:
A redirect is a way to forward visitors and search engines to a different URL than the URL they requested.
When content has been moved from one URL to another URL.
Examples in which redirects should be used:
When moving content from one URL to another URL, you want both visitors and search engines to easily find the new URL. This gives visitors a good user experience (none of us like 404 pages), while giving search engines a helping hand in finding the new URL.
Redirects can be divided into server-side redirects and client-side redirects. Both types of redirects can be implemented in various ways. Be very careful about your choice for the type of redirect: choosing the wrong redirect for the job could lead to SEO troubles.
A server-side redirect is a forwarding method in which a HTTP status code is used when a visitor requests a URL. The server then determines what URL the visitor should be sent to.
The most common HTTP status codes are:
When it comes to redirects, the 301 redirect usually is your best choice. A 301 redirect is used when you want to signal that content has been permanently moved to another URL. The general consensus is that a 301 redirect passes around 90-95% of the page authority from an old URL to a new URL. A visitor won’t notice the difference between a 301 redirect and a 302 redirect, but for a search engine this is a completely different signal.
Be careful about using 301 redirects when the actual redirection isn’t permanent. If you intent to remove the 301 redirect shortly after implementing it: be prepared to wait several weeks, if not months to see the redirected URL back in the search engine’s indexes.
A 302 redirect is used to signal that content has temporarily been moved to another URL. A 302 redirect passes no page authority from the old URL to a new URL. A 302 redirect is rarely used since in most cases you want to pass a page’s authority and only a 301 redirect will let you do that.
Situations in which it’s absolutely fine to use 302 redirects:
A 303 redirect should only be used after a visitor of your website submitted a form. Using this redirect type ensures the visitor won’t be able to re-submit the form when using the back-button in her browser. The 303 redirect should not be used when you need to redirect URLs after content has moved.
In HTTP 1.1, a 307 redirect is the equivalent of the 302 redirect in HTTP 1.0. Similar to the usage of 302 redirects, a 307 redirect should only be used when content has been temporarily moved to another URL. Since a 307 redirect does not pass page authority, in most cases a 301 redirect should be used.
Worth noting: the type of HTTP method used to do a request doesn’t change when the server responds with a 307 redirect. The request is then made from another resource while the HTTP method stays the same.
The 308 redirect, available only in HTTP 2.0, is the permanent version of the 307 redirect. As can be expected with a permanent redirect, the 308 redirect does pass page authority.
Similar to the 307 redirect, the 308 redirect keeps the originally used HTTP method.
A client-side redirect is a forwarding method in which a visitor’s browser handles redirection. Using client-side redirects has several drawbacks, namely:
Due to these reasons we strongly recommend not to use client-side redirects.
The meta refresh element is used to instruct a browser to refresh the current page, or load another URL. An example of what the meta refresh element looks like:
When using redirects, keep the best practices below in mind to make sure you offer your visitors an optimal user experience and you preserve as much page authority as you can.
Yes, you read it correctly: avoid using redirects whenever you can. They slow down load time and waste crawl budget.
Please note that it’s totally fine to use 301 redirects for configuring your webserver so it serves URLs according your preferences (e.g. usage of subdomain and trailing slash).
When using redirects, be vigilant for chained redirects. A chained redirect is when one URL is requested, a redirect is used to redirect it to another URL and in turn this particular URL is redirected as well. Since not all page authority is passed in a redirect, having a chained redirect with one or more extra hops is surely not improving the amount of passed page authority.
It’s important to choose a preferred version of your website URL and stick with it. Below we describe two important topics you need to think about when linking. Consistently using the preferred version of your website URL prevents unnecessary redirects which cause loss of page authority.
For example: if you prefer to have your website on the ‘www’ subdomain make sure requests for URLs without the ‘www’ subdomain are 301 redirected to the version with the ‘www’ subdomain. Remember: for search engines
example.com are two separate domains.
Choose your preference when it comes to trailing slashes as well. For search engines
www.example.com/page-a/ are different URLs. When both URLs serve the same page, and no canonical URL or
meta name=”robots” content=”noindex” is used, then this causes you to have duplicate content. If you prefer the trailing slash: make sure requests to the version of the page without the trailing slash are redirected to the version with the trailing slash.
People will link to your website the way they want to. Often they do not adhere to your preferred version of your website URL. They may link to your contact page with the URL
http://yourdomain.com/contact while your URL in reality lives on
http://www.yourdomain.com/contact/. When you’ve correctly configured your webserver visitors will end up on the right URL, but you’ll lose a bit of authority in the redirect. Monitor your inbound links with a tool such as Majestic and reach out to the ones linking to the wrong version of your URLs.
Tons of websites employ campaign URLs to support their online and offline campaigns. After such a campaign, these URLs are often redirected. When a campaign is simply inactive and will return in the future use a 302 redirect to be able to bring the campaign URL back to the search engine indexes when you need it again.
When you’re absolutely sure a campaign URL will never be used anymore, it’s safe to 301 redirect the URL to the most relevant URL within your website. If there’s any doubt about it, use a 302 redirect so you basically have the URL on standby. The URL will remain in the index and the URL can be used to rank again in the search engines.
Having (hundreds of) thousands of redirects may, depending on the way the redirects are implemented, slow a website down significantly. On top of that, sometimes old redirects play a vital role in strange website behavior. An old redirect could be causing inexplicable behaviour within your website. Keep things simple, keep the amount of redirects within your website to a minimum. Periodically check which redirects are necessary and which redirects can be cleaned up. Only URLs that have inbound links and/or get serious referral traffic should be redirected. These URLs can be found by analyzing the inbound links to pages on your website using services such as Majestic and Ahrefs combined with referral data from your webanalytics service. All URLs that redirect but have no inbound links and referring traffic can be removed.
IP canonicalization is the process of implementing redirects for an IP-address to a domainname. This is done to prevent duplicate content.
If your webserver is incorrectly set up it may serve your website both for your webserver’s IP address and your domain name. Aside from the strange user experience, having your website accessible to search engines both through your IP address and domain name leads to duplicate content and should be avoided. Good news, a solution to this problem is not that hard. If you’re using Apache webserver, this can be fixed by including the code below in your .htaccess file.
Note: replace 184.108.40.206 with your server IP address, and example.com with your domain name.
Traditionally URL redirects had to be configured on the webserver level. Nowadays most common Content Management Systems offer at least basic support for configuring URL redirects.
Setting up URL redirects in a CMS has the benefit that it’s much more accessible for people without a development or system administration background but it comes at a cost. When there are problems with the CMS the redirects might stop working and in most cases the redirects will be slower, as the CMS needs to be loaded for every redirect. On top of that, redirects set up within the CMS and on webserver level can co-exist leading to confusion and possible mistakes.
Therefore it’s always advisable to set up URL redirects on the webservers, and only use CMS redirects when there is no other way to do so.
Regular expressions is a language which can be used to search within text using patterns. For example, to search in a string of text for digits the regex
[0-9] can be used. Another example is using regex to match optional characters.
filename.html? matches both filename.htm and filename.html.
Regular expressions are extremely useful for setting up redirects, as it saves you the hassle of setting up redirects for individual URLs. For example, let’s say you have the following URL-structure:
then instead of setting up three different redirect rules you can use the following regular expression to match all these subdirectories:
When you are using the Apache webserver you need to use the
RewriteEngine which is part of the
modrewrite-module. This module is usually loaded by default in Apache, but if not make sure that you load it specifically in your Apache configuration using the following directive:
When the module is loaded you can set up redirects using the following formatting:
This will instruct Apache to redirect all subdirectories of /blog/ (the categories) to the new location in /news/.
Another common use-case of redirecting URLs is to ensure that all URLs include the ‘www’-part of your domain name. In that case you can set up a rewrite rule that only runs when a certain condition (the URL not containing the ‘www’-part of the domain name) is met.
This rewrite rule redirects all URLs to the version that includes the ‘www’-part, but only if that part is actually missing (the rewrite condition).