1. SEO Wiki
  2. Redirect

Redirect

Definition

A redirect is a way to send both users and search engines to a different URL than the one they originally requested[1]. When a user or a search engine requests a URL that has been redirected, the web server returns a response with a different URL, called the destination URL. The browser or search engine then automatically loads the destination URL.

How redirection works

How redirection works

Server-side redirects

Server-side redirects are a type of redirect that are implemented on the web server. They are executed by the web server when a user or a search engine requests a URL, and they allow the server to direct the user or search engine to a different URL than the one they originally requested.[2]

There are different ways to implement server-side redirects, depending on the web server software that is being used. For example, in Apache, server-side redirects can be implemented using the mod_rewrite module, while in Nginx they can be implemented using the rewrite directive.

Here are a few examples of server-side redirects:

Permanent redirects

Permanent redirects show the new redirect target in search results.

301 redirect: This type of redirect is used to permanently redirect a user or a search engine from an old URL to a new URL. It is considered a best practice for SEO as it passes almost all of the link juice (ranking power) to the destination URL and also informs search engines that the old URL should no longer be indexed and should be replaced by the new one.

Temporary redirects

Temporary redirects show the source page in search results.

302 redirect: This type of redirect is used to temporarily redirect a user or a search engine from an old URL to a new URL. It does not pass any link juice to the destination URL and also it does not inform search engines that the old URL should no longer be indexed.

307 redirect: This type of redirect is similar to 302 redirect, but it forces the browser to resend the original request method (POST, GET, etc) to the new location.

Client-side redirects

Client-side redirects, also known as client-side forwarding or JavaScript redirects, are a type of redirect that are executed by the browser, rather than on the server-side. They are implemented by adding JavaScript code to a webpage, which directs the user or a search engine to a different URL than the one they originally requested.[2]

Here are a few examples of client-side redirects:

window.location: This method can be used to redirect a user to a new URL by changing the value of the window.location property. It's very simple and easy to use, but it doesn't inform the search engine that the redirect is taking place.

window.location.href: This method can be used to redirect a user to a new URL by changing the value of the window.location.href property. It's very similar to the previous method but it also sends the current page's referrer along with the redirect.

window.location.replace: This method can be used to redirect a user to a new URL by changing the value of the window.location.replace property. This method replace the current history entry with the new URL, so user can't go back to the previous page using the browser's back button.

window.location.assign: This method can be used to redirect a user to a new URL by changing the value of the window.location.assign property. It's similar to the previous method but it creates a new history entry for the new URL.

Application

Redirects can be useful for a variety of reasons, such as:

  • redirecting users and search engines from an old URL to a new URL after a website redesign
  • redirecting users and search engines from non-www to www or vice versa
  • redirecting users and search engines from HTTP to HTTPS
  • redirecting users and search engines to a different language version of the website

Redirects and SEO

Redirects are an important aspect of SEO because they help to ensure that users and search engines are directed to the correct URL, even when the original URL has been changed or removed. When used correctly, redirects can help to improve the user experience and maintain the integrity of a website's search engine rankings.

Here are a few ways in which redirects can impact SEO:

  • Preserving search engine rankings: When a website is redesigned or a URL is changed, it's important to use a 301 redirect to ensure that search engines and users are directed to the correct URL. This can help to preserve the search engine rankings of the original URL and ensure that traffic is not lost.
  • Avoiding duplicate content: When a website has multiple URLs that lead to the same content, it can cause search engines to see the content as duplicate. Using redirects to direct all traffic to a single URL can help to avoid duplicate content issues and ensure that search engines only index the correct URL.
  • Improving user experience: When a user requests a URL that has been removed or changed, it's important to use a redirect to ensure that they are directed to the correct URL. This can help to improve the user experience and ensure that users are able to find the information they are looking for.
  • Avoiding crawl errors: When a search engine crawls a website and encounters a 404 error, it's considered a crawl error, which is bad for SEO. Using redirects can help to avoid crawl errors by directing the search engine to the correct URL.

It's important to keep in mind that too many redirects or redirect chains (redirecting from one URL to another URL that redirects again) can be detrimental for SEO and can slow down the loading time of a website. Also, using the wrong type of redirects (302 instead of 301) can cause the link juice and search engine rankings to be lost. Therefore it's important to use redirects judiciously, only when necessary and to ensure they are set up correctly and properly.

The Essential SEO Guide to URL Redirects