Technical SEO

Redirects

Shahid Maqbool

By Shahid Maqbool
On May 1, 2023

Redirects

What are redirects?

In SEO, redirects are a way to send website visitors and search engines from one URL to another.

They are used to maintain the website's search engine rankings and to ensure that visitors can still access the content they are looking for even if the original URL has changed.

It is important to use redirects correctly to avoid negative impacts on SEO and to provide a seamless user experience.

Why are redirects important?

Redirects play an essential role in the world of SEO and website management. 

  • They allow website owners to send users and search engines to new URLs while retaining the SEO value of the old page. Redirects are critical for maintaining a website's search engine rankings.

  • They ensure that visitors can still find the content they're looking for even if the URL has changed. Without redirects, visitors would encounter 404 error pages, which can be frustrating and confusing, leading to a poor user experience. 

  • Additionally, if a website's URL structure changes, search engines may still have the old URLs indexed, resulting in a loss of traffic and reduced visibility in search results. Redirects help to avoid these problems by signalling to search engines that the content has moved, preserving the website's ranking and visibility. 

Using redirects correctly is essential for maintaining website functionality and maximizing the SEO value of your content.

Why do we use redirects?

There are several reasons why redirects are commonly used in website management and SEO. 

To keep the content accessible during structural changes 

One primary reason is to maintain the website's search engine rankings and prevent a loss of traffic.

Redirects ensure that visitors can still access the content they're looking for, even if the URL has changed or the content has been moved.

This is especially important when a website undergoes structural changes, such as redesigns or updates, as redirects can help preserve the SEO value of the old content.

To consolidate content

Redirects can also be used to consolidate content from multiple pages into a single URL, improving the overall user experience and making it easier for search engines to crawl and index the website.

For example, if a website has several pages with similar or identical content, redirects can be used to consolidate those contents onto a single page, improving the website's structure and reducing duplicate content issues.

To redirect users while fixing errors

Furthermore, redirects can be used to fix errors, such as broken links, misspelt URLs, or outdated content.

By using a redirect, website owners can ensure that users are sent to the correct page or content, improving the user experience and reducing the likelihood of visitors leaving the site due to errors or frustration.

To move the URL of a webpage

If you change the URL of a webpage, you'll need to set up a redirect from the old URL to the new URL. This ensures that users can still access the content they're looking for if in case they visit the old URL.

To delete a page

If you delete a page from your website, you set up a redirect to another relevant page on your site. This will prevent users from landing on a "404 error" page and will help to preserve any SEO value that the deleted page may have had.

Adding category tags or parent pages that affect URLs

If you add or remove category tags or parent pages, it can affect the URLs of your web pages. In this case, you'll need to set up redirects to ensure that any old URLs still work and that search engines can update their indexes with the new URLs.

Moving your website to a new domain

If you move your website to a new domain, you should set up redirects from the old domain to the new one.

This ensures that any inbound links to your site still work and that users can still find your site via search engines.

Performing maintenance on a webpage

If you're performing maintenance on a webpage, you may need to temporarily redirect users to another page or a maintenance page using 302 redirects.

This can prevent users from seeing broken pages or error messages while you work on your site.

Migrating your site from HTTP to HTTPS

If you're migrating your site from HTTP to HTTPS, you'll need to set up redirects from the old HTTP URLs to the new HTTPS URLs.

This ensures that users can still access your site, and it helps to preserve any SEO value that your site may have had.

Types of redirects

There are two major types of redirects:

  1. Client-side redirect

  2. Server-side redirects

Client-side redirects

They are executed by the user's browser. This means that when a user visits a page with a client-side redirect, their browser will receive the redirect instructions and will immediately send them to the new destination URL.

Client-side redirects are typically implemented using JavaScript or meta-refresh tags.

Client-side redirects can be useful in certain situations, such as when you want to track clicks on a particular link, or when you need to redirect users to an external site that you don't control.

Meta Refresh

A meta refresh is a type of redirect that automatically sends visitors to a different page after a set period of time.

Meta refresh redirects can be problematic from an SEO perspective as they can be abused to artificially inflate pageviews and reduce the time spent on the site. As a result, they should be used with caution and only in specific situations.

Google also does not recommend it:

John Mueller on meta refresh

Javascript redirects

A JavaScript redirect is a technique used to redirect a user from one web page to another using JavaScript code.

Unlike server-side redirects, which are handled by the web server and return an HTTP status code, JavaScript redirects are initiated on the client-side, within the user's web browser.

To implement a JavaScript redirect, the web developer typically adds a short piece of code to the original web page that triggers the redirect.

The code can use the window.location property to specify the URL of the new web page, and the window.location.replace() method to replace the current web page with the new one.

For example, the following code will redirect the user to the specified URL after a 3-second delay:

<script>

  setTimeout(function() {

    window.location.replace("https://www.example.com/new-page");

  }, 3000);

</script>

JavaScript redirects can be useful in some situations where a server-side redirect is not possible or desirable.

For example, they can be used to create a client-side redirect after a user submits a form or clicks on a button, without requiring a page reload. 

However, it's important to use JavaScript redirects carefully, as they can be disruptive to the user experience and can also impact SEO, as most of the search engines can’t follow them.

Server-side redirects

Server-side redirects are executed by the web server before the page is served to the user's browser.

This means that when a user visits a page with a server-side redirect, the web server will handle the redirect and will send the user's browser to the new destination URL.

Server-side redirects are typically implemented using server configuration files, such as .htaccess files for Apache servers, or using server-side scripts like PHP or ASP.

The main advantage of server-side redirects is that they are faster and more reliable than client-side redirects.

Since the redirect is handled by the server before the page is served to the user's browser, the user will be sent directly to the new destination URL without any delay or additional processing. This can help to improve website performance and provide a better user experience.

Server-side redirects can be both permanent and temporary and have the following types:

301 Redirects (permanent)

A 301 redirect is a permanent redirect that indicates that the original URL has permanently moved to a new URL.

301 redirects are ideal for situations where content has been permanently removed or relocated, as they signal to search engines to update their index with the new URL.

According to Gary Illyes, it is recommended to maintain 301 permanent redirects for a minimum of one year, and ideally, for an indefinite period. This is beneficial for user experience.

Gary Illyes tweet about redirects

By keeping these redirects in place, Google is given enough time to recognize the change and transfer all ranking signals from the old URL to the new one.

302 Redirects (temporary)

A 302 redirect is a temporary redirect that indicates that the original URL is still valid, but the content has been temporarily moved to a new URL.

302 redirects are useful for situations where a page or content is temporarily unavailable or when testing new content without replacing existing content.

303 redirect (temporary)

A 303 redirect is a type of HTTP status code that indicates that a resource has been created and can be found at a different URL.

It is a relatively uncommon type of redirect, as most website owners and developers opt for the more commonly used 301 or 302 redirects.

A 303 redirect is often used in situations where a user submits a form or completes a request, and the server needs to provide a response indicating that a new resource has been created.

The response includes a new URL where the user can access the newly created resource, and the 303 status code indicates that the original URL should not be used to access the resource.

For example, suppose a user completes a form on a website to sign up for a newsletter. In that case, the server may respond with a 303 status code and a new URL where the user can access the newsletter content.

307 redirect (temporary)

A 307 redirect is an HTTP status code that indicates that a resource has temporarily moved to a new URL. It is a type of temporary redirect, similar to a 302 redirect.

Like a 302 redirect, a 307 redirect instructs web browsers to visit a new URL to retrieve the resource requested by the user.

The difference between a 302 redirect and a 307 redirect is that a 307 redirect instructs the browser to make the request using the original HTTP method used in the original request. In contrast, a 302 redirect may change the HTTP method used in the original request.

In practical terms, this means that a 307 redirect is often used in situations where a website or web application needs to redirect a user to a new URL temporarily, but it's important to maintain the original HTTP method.

This could be useful in situations where a user submits a form, for example, and the website needs to redirect the user to a different URL temporarily to complete the request while ensuring that the original form data is still submitted correctly.

308 redirect (permanent)

A 308 redirect is an HTTP status code that indicates a permanent redirect, similar to a 301 redirect. However, unlike a 301 redirect, a 308 redirect instructs web browsers to use the same HTTP method for the new URL as was used for the original request.

This means that if a user accesses a resource using a POST request, and the server responds with a 308 status code and a new URL, the browser will automatically send a POST request to the new URL.

In contrast, a 301 redirect or a 302 redirect may change the HTTP method used in the original request.

Other types include:

  • Canonical Redirects

A canonical redirect is a type of redirect used to consolidate multiple versions of the same content into a single, canonical version.

This is important for SEO because search engines can penalize sites that have duplicate content, as it can be difficult for the search engine to determine which version of the content is the "correct" one to show in search results.

A canonical redirect works by redirecting all non-canonical versions of a URL to the canonical version.

For example, if you have multiple versions of a product page with different URLs (such as www.example.com/product and www.example.com/products), you can set one of the URLs as the canonical version and redirect all other versions to it.

This tells search engines that the canonical version is the "official" version of the page, and helps to consolidate the page's authority and improve its search ranking.

  • Redirect Chains

Redirect chains occur when multiple redirects are used to send a user from one URL to another. While redirect chains can be used in some situations, they should generally be avoided, as they can slow down page load times and negatively impact SEO.

Best practices for redirection

Redirect to a relevant URL

If a page is no longer available or has been moved, it's important to redirect users to a relevant alternative URL.

This could be a similar or related page that contains similar information or the same information on a different URL. This ensures that users are still able to access the content they were looking for.

Avoid chained redirects

Redirect chains can cause performance issues, and can confuse search engines. To avoid this, it's best to create direct redirects to the final destination page whenever possible.

Redirect to the preferred version of your website URL

If your website is available on multiple versions of the same URL (e.g., with or without the www prefix), it's important to redirect users to the preferred version of the URL.

This helps ensure that all traffic is directed to a single, canonical version of the site, which can help avoid issues with duplicate content and other SEO problems.

Use a 302 redirect for inactive campaign URLs

If you have URLs that are associated with specific marketing campaigns or events that are no longer active, it's best to use a 302 temporary redirect.

This ensures that users are directed to the relevant page until that campaign is not active again, and the redirect will be removed once the campaign is started again.

Use a 301 redirect for campaign URLs

For URLs that are associated with marketing campaigns or events that will never be used again, it's best to use a 301 permanent redirect.

This ensures that users are always directed to the most relevant, up-to-date page, and also helps maintain the SEO value of the original page.

Clean them up

Over time, your website may accumulate multiple redirect chains that are no longer needed. It's important to periodically review any redirect chains and clean them up.

IP Canonicalization

IP canonicalization is a technique used to ensure that search engines and users are directed to the correct IP address for a website.

This is particularly important if you have multiple IP addresses associated with your site or if your site uses a content delivery network (CDN).

To ensure that IP canonicalization is working correctly, make sure that your server is set up to redirect all requests to the preferred IP address.

How to set them up?

Through plugins

Plugins are third-party add-ons that can be installed and used to extend the functionality of your website.

Many content management systems (CMS) offer plugins that make it easy to set up redirects without having to edit configuration files manually.

Example:

If you have a WordPress website, you can install a plugin like "Redirection" to manage your redirects.

After installing the plugin, you can access its interface through the WordPress dashboard, where you can create, edit, and manage your redirects without needing to edit your .htaccess file.

Through your CMS

Many content management systems have built-in tools for managing redirects. These tools are often part of the CMS's administrative interface and allow you to create, edit, and manage redirects without having to deal with server configuration files.

Example:

In Drupal, you can use the "Redirect" module to manage redirects. After installing the module, you can access the Redirect interface through the Drupal administrative dashboard, where you can add and manage redirects directly within the CMS.

Through an .htaccess file

An .htaccess file is a configuration file used by Apache web servers. It allows you to set up redirects and rewrite rules at the directory level.

This method requires manual editing of the .htaccess file, and you need to have access to the file on your web server.

Example:

To create a simple 301 redirect in an .htaccess file, you can add the following line of code:

Redirect 301 /old-page /new-page

Single URL Redirect

A single URL redirect is when you want to redirect one specific URL to another. This is useful when you have changed the URL of a page and want to ensure that users are directed to the updated page.

Example:

Suppose you have an old URL "website.com/old-page" and want to redirect users to "website.com/new-page". In your .htaccess file, you would add the following line:

Redirect 301 /old-page /new-page

Redirect All Except

Sometimes you may want to redirect all URLs of a website to a specific page, except for a few specific URLs.

This is useful when you want to direct users to a maintenance page while still allowing access to certain parts of your site.

Example:

You want to redirect all pages to a maintenance page except the "/admin" and "/login" pages. In your .htaccess file, you would add:

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/admin

RewriteCond %{REQUEST_URI} !^/login

RewriteRule .* /maintenance-page [R=302,L]

Directory Change

When you change the directory structure of your website, you can use a directory change redirect to ensure that users can still access the content.

Example:

You've moved all your blog posts from "website.com/blog/" to "example.com/articles/". In your .htaccess file, you would add:

RedirectMatch 301 ^/blog/(.*) /articles/$1

Remove A Word From the URL

If you want to remove a specific word from all URLs on your website, you can use a redirect rule.

Example:

You want to remove the word "category" from all URLs. In your .htaccess file, you would add:

RewriteEngine On

RewriteRule ^(.*)category/(.*)$ /$1$2 [R=301,L]

HTTP To HTTPS Redirect

When you switch your website from HTTP to HTTPS, you should set up a redirect to ensure users are directed to the secure version of your site.

Example:

In your .htaccess file, you would add:

RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Redirect From Old Domain To New

If you change your domain name, you should set up a redirect to ensure users can still access your site using the old domain.

Example:

You want to redirect all traffic from "olddomain.com" to "newdomain.com". In the .htaccess file of the old domain, you would add:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^olddomain.com [NC]

RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]

Conclusion

Redirects are a powerful tool for managing website content and improving user experience. Whether you're reorganizing your site's structure, updating URLs, or consolidating duplicate pages, redirects can help ensure that visitors are always directed to the most relevant and up-to-date content.

However, it's important to use redirects carefully and strategically to avoid confusing search engines or frustrating users with broken links.

Related Articles

Leave a reply
All Replies (0)