Clicky

URL Redirects For SEO: A Technical Guide

Redirects for SEO must be used correctly because they affect how websites are crawled and indexed by Google.

While most people think of redirects as an internet detour sign, there’s a lot more going on, and it’s surprisingly nice to discover.

Read on for a comprehensive overview of redirects and the proper application for technical SEO.

What Is A Redirect?

Website redirects tell browsers and search engines information about a URL and where to find the web page.

A URL redirect involves code executed to a specific URL, or group of URLs so that the user (or search engine) is sent to a different page to the actual URL that was entered or clicked.

When To Use Redirects

The main reasons to use redirects are:

For SEO purposes, URL redirects are important because they:

Redirects can be implemented on a group or domain basis but often must be configured on an individual basis to avoid problems.

When using RegEX for group redirects, it can have unexpected results if your logic isn’t perfect!

Types Of Redirects

There are three main types of redirects:

What Is A HTTP Response Status Code?

Browsers and search engines like GoogleBot are called user agents.

When a user agent tries to access a web page, what happens is that the user agent makes a request, and the web server provides a response.

The response is called an HTTP response status code. It provides status for the URL request.

In the situation where a user agent like GoogleBot requests a URL, the server provides a response.

For example, if the URL request is successful, the server will provide a response code of 200, which means that the URL request was successful.

So, when you think GoogleBot reaches a website and tries to crawl it, what happens is a series of requests and responses.

HTTP Redirects

An HTTP redirect is a server response to request a URL.

If the URL exists at a different URL (because it has been moved), the server tells the user agent that the URL request is being redirected to a different URL.

The response code for a changed URL is usually in the form of a 301 or 302 response status code.

The entire 3xx series of response codes communicates a wealth of information that the user agent can optionally act upon.

An example of an action the user agent can take is to cache the new URL so that the next time the old URL is requested, it will request the new URL instead.

So, a 301 and 302 redirect is more than an internet road sign that says, “Go here, not there.”

3XX Series Of Status Codes

Redirects are more than just the two status codes everyone is familiar with, the 301 and 302 response codes.

There are a total of seven official 3xx response status codes.

These are the different types of redirects available for use:

Some of the above status codes have not been around that long and may not be used. So, before using any redirect code other than 301 or 302, make sure that the intended user agent can interpret it.

Since GoogleBot uses the latest version of Chrome (called the headless browser), it’s easy to check if a status code is compatible by checking if Chrome recognizes the status code with a browser compatibility list.

For SEO, stick to using the 301 and 302 response codes unless there is a specific reason to use one of the other codes.

301: Moved Permanently

The 301 status code is routinely referenced as the 301 redirects. But the official name is 301 Moved Permanently.

The 301 redirect indicates to a user agent that the URL (sometimes referred to as a target resource or simply a resource) has been changed to another location and that it should use the new URL for future requests.

As mentioned before, there is also more information.

The 301 status code also suggests to the user agent:

That last point is a technical matter. According to the official standards for the 301 status code:

“Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is unwanted, the status code 308 (Permanent Redirect) can be used instead.”

For SEO, when search engines see a 301 redirect, they pass the rank of the old page to the new one.

Before making a change, you should be careful when using a 301 redirect. The 301 redirects should only be used when the change to a new URL is permanent.

The 301 status code should not be used when the change is temporary.

Additionally, if you change your mind later and go back to the old URL, the old URL may no longer rank and it may take time to regain the rankings.

So, the main thing to remember is that a 301 status code will be used when the change is permanent.

302: Found

The main thing to understand about the 302 status code is that it is useful for situations where a URL has been temporarily changed.

The meaning of this response code is that the URL is temporarily at a different URL, and it is suggested to use the old URL for future requests.

The 302 redirect status code also comes with a technical caveat related to GET and Post:

“Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is unwanted, the status code 307 (Temporary Redirect) can be used instead.”

The reference to “historical reasons” may refer to old or buggy user agents that may change the request method.

307: Temporary Redirect

A 307 redirect means that the requested URL has been temporarily moved, and the user agent must use the original URL for future requests.

The only difference between a 302 and a 307 status code is that a user agent must request the new URL with the same HTTP request used to request the original URL.

That means if the user agent requests the page with a GET request, then the user agent must use a GET request for the new temporary URL and cannot use the POST request.

The Mozilla documentation of the 307 status code explains it more clearly than the official documentation.

“The server sends this response to direct the client to obtain the requested resource at another URI using the same method that was used in the previous request.

This has the same semantics as the 302 Found HTTP response code, with the exception that the user agent must not change the HTTP method used: if POST was used in the first request, POST must be used in the second request.”

Apart from the 307 status code requiring subsequent requests to be of the same type (POST or GET) and that the 302 can go both ways, everything else is the same between the 302 and the 307 status codes.

302 Vs. 307

You can handle redirection with server configuration files .htaccess on Apache, example.conf file on Nginx or with plugins if you use WordPress.

In all cases, they have the same syntax for writing redirection rules. They differ only with commands used in configuration files. For example, a redirect on Apache will look like this:

(You can read about symbolic links here.)

On Nginx servers, it will look like this:

The commands used to tell the redirect server status code and the action command are different.

But the redirection syntax ( ^/old directory/ /new directory/ ) is the same for both.

On Apache, make sure mod_rewrite and mod_alias modules (responsible for handling redirects) are enabled on your server.

Since the most widespread server type is Apache, here are examples for .htaccess Apache files.

Make sure the .htaccess file has these two lines above the redirect rules and place the rules below them:

Read the official documentation to learn more about the RewriteEngine.

To understand the examples below, you can refer to the RegExp basics table below.

How To Create Redirects

How To Create A Redirect For A Single URL

The most common and widely used type of redirect is when you delete pages or change URLs.

For example, say you changed the URL from /old-page/ to /new-page/. The redirect rule would be:

The only difference between the two methods is that the first uses the Apache mod_rewrite module, and the second uses mod_alias. It can be done by either method.

The regular expression “^” means that the URL must start with “/old page” while (/?|/.*)$ indicates that everything that follows “/old page/” with a slash “/” or without exact . compatibility should be redirected to /new-page/.

We could also use (.*), i.e., ^/old-page(.*), but the problem is, if you have another page with a similar URL like /old-page-other/, it will also be redirected when we want just redirect /old page/.

The following URLs will match and be directed to a new page:

It will redirect any variation of the page URL to a new one. If we use a redirect in the following form:

Without regular expressions, all URLs with a UTM query string, e.g., /old-page?utm_source=facebook.com (which is common because URLs tend to be shared across a social network), will end up as 404s.

Even a /old page without a backslash “/” would end up as a 404.

Redirect All Except

Let’s say we have a set of URLs like /category/old-subcategory-1/, /category/old-subcategory-2/, /category/final-subcategory/ and want to merge all the subcategories into /category/final-subcategory/ . . We need the “all but” rule here.

Here, we want to redirect everything under /category/ on the third line unless it’s /category/final-subcategory/ on the fourth line. We also have the rule “!-f” on the second line, ignoring any file like images, CSS or JavaScript files.

Otherwise, if we have some assets like “/category/image.jpg”, it will also be redirected to “/final-subcategory/” and cause image breakage.

Directory Change

You can use the rule below if you have done a category rearrangement and want to move everything from the old folder to the new one.

I used $1 in the target to tell the server to remember everything in the URL that follows /old-folder/ (ie, /old-folder/subfolder/) and pass it (ie, “/subfolder/”) to the destiny As a result, it will be redirected to /new-folder/subfolder/.

I used two rules: one case with no backslash at the end and the other with a backslash.

I could combine them into one rule using (/?|.*)$ RegExp at the end, but it would cause problems and add a “//” slash to the end of the URL when the requested URL without a backslash has a query string (ie , “/old-directory?utm_source=facebook” would be redirected to “/new-directory//?utm_source=facebook”).

Remove A Word From URL

Let’s say you have 100 URLs on your site with the city name “Chicago” and want to remove them.

For the URL http://yourwebiste.com/example-chicago-event/, the redirect rule would be:

If the example URL is in the form http://yourwebiste.com/example/chicago/event/, then the redirect would be:

Set A Canonical URL

Having canonical URLs is the most important part of SEO.

If missing, you could put your website at risk with duplicate content issues because search engines treat URLs with “www” and “non-www” versions as different pages with the same content.

Therefore, you should make sure that you only run the website with one version that you choose.

If you want to run your site with the “www” version, use this rule:

A backslash is also part of canonicalization because URLs with or without a trailing slash are also treated differently.

This will ensure that the /example-page is redirected to /example-page/. You can choose to remove the slash instead of adding, then you will need the other rule below:

HTTP To HTTPS Redirect

After Google’s initiative to encourage website owners to use SSL, migrating to HTTPS is one of the commonly used redirects that almost every website has.

The rewrite rule below can be used to force HTTPS to every website.

Using this, you can combine www or non-www version redirects into one HTTPS redirect.

Redirect From Old Domain To New

This is also one of the most used redirects when you decide to rebrand and need to change your domain. The rule below redirects old-domain.com to new-domain.com.

It uses two cases: one with the “www” version of URLs and another “non-www” because any page for historical reasons can have incoming links to both versions.

Most website owners use WordPress and may not need a .htaccess file for redirects but use a plugin instead.

Handling redirects using plugins can be a little different than what we discussed above. You may need to read their documentation to handle RegExp correctly for the specific plugin.

Of the existing ones, I would recommend a free plugin called Redirect, which has many parameters to control redirects and many useful documents.

Redirect Best Practices

1. Don’t Redirect All 404 Broken URLs To The Homepage

This case often happens when you are too lazy to research your 404 URLs and map them to the appropriate landing page.

According to Google, they are still all treated as 404s.

Yeah, it’s not a great practice (confuses users), and we mostly treat them as 404s anyway (they’re soft-404s), so there’s no advantage. It’s not critically broken/bad, but added complexity for no good reason – make a better 404 page instead.

— 🍌 John 🍌 (@JohnMu) January 8, 2019

If you have too many pages like this, you should consider creating nice 404 pages and engaging users to browse further or find something other than what they were looking for by showing a search option.

Google strongly recommends that redirected page content be equivalent to the old page. Otherwise, such a redirect can be considered a soft 404, and you will lose the rank of that page.

2. Get Mobile Page-Specific Redirects Right

If you have different URLs for desktop and mobile sites (ie, “example.com” for desktop and “m.example.com” for mobile), you should make sure to redirect users to the appropriate page on the mobile version.

Correct: “example.com/sport/” to “m.example.com/sport/” Incorrect: “example.com/sport/” to “m.example.com”

Also, you need to make sure that if one page is 404 on desktop, it should also be 404 on mobile.

If you don’t have a mobile version for a page, you can avoid redirecting to the mobile version and keep them on the desktop page.

3. How To Use Meta Refresh

It is possible to make a redirect using a meta-refresh tag like the example below:

<meta http-equiv=”refresh” content=”0;url=http://example.com/new-page/” />

If you include this tag in /old-page/, it will immediately redirect the user to /new-page/.

Google does not prohibit this redirect, but it does not recommend using it.

A meta refresh type redirect should just work. We don’t recommend it for 2 reasons: UX (it saves the page in browser history, afaik) & processing time (we need to parse the page to see it). Once processed, it is only as a redirect.

— 🍌 John 🍌 (@JohnMu) March 2, 2018

According to John Mueller, search engines may not be able to recognize that type of redirect correctly. The same applies to JavaScript redirects as well.

4. Avoid Redirect Chains

This message appears when you have an incorrect regular expression setting and ends up in an infinite loop.

Screenshot by author, December 2022

Usually, this happens when you have a redirect chain.

Let’s say you redirected page 1 to page 2 a long time ago. You may have forgotten that page 1 was redirected and decided to redirect page 2 to page 1.

As a result, you will end up with a rule like this:

This will create an infinite loop and produce the error shown above.

Conclusion

Knowing what redirects are and which situation requires a specific status code is fundamental to properly optimizing web pages. It is a core part of understanding SEO.

Many situations require precise knowledge of redirects, such as migrating a site to a new domain or creating a temporary home page URL for a web page that will return under its normal URL.

Although so much is possible with a plugin, plugins can be misused without properly understanding when and why to use a particular type of redirect.

How do I redirect my domain to another domain for SEO?

How to change a domain – a guide to SEO best practices

  • Implement 301 redirects. A thorough 301 redirect strategy is the most important part of a successful domain switch. …
  • Update links. …
  • Crawl the site. …
  • Set up Google Search Console. …
  • Submit your sitemap. …
  • Submit a change of address. …
  • Continue to own and host your old domain name.

Can I redirect from one domain to another domain? URL redirection (URL forwarding) allows you to forward your domain visitors to any URL of your choice (to a new domain or a different website). You can set 301 (Permanent), 302 (Unmasked) and Masked (URL Frame) redirects for the domain names pointed to BasicDNS, PremiumDNS or FreeDNS.

Do domain redirects help SEO?

Are redirects bad for SEO? Well, it depends, but most of the time no. Redirects are not bad for SEO, but – as with so many things – only if you place them correctly. Poor implementation could cause all sorts of problems, from losing PageRank to losing traffic.

Does Google penalize domain forwarding?

No, Google will not penalize a site for having 15 redirects (or any other number). Also, you may be able to redirect a penalty to your own site, but I’ve covered that many times. It is not as simple as it sounds. Do some searches on this site for redirect penalties and you will see.

Why redirects are important for SEO?

Redirects solve this problem by seamlessly sending visitors to the new location of the content. Help search engines understand your site â Redirects tell search engines where content has moved and whether the move is permanent or temporary. This affects if and how the pages appear in their search results.

Will 301 redirects hurt SEO?

This means that 301 redirects do not harm SEO performance or reduce the âPageRankâ metrics associated with a page URLâ although they are not crucial to search rankings either. All 300-level server-side redirects pass PageRank to the landing page (including 301 redirects as well as 302s, and 307s).

Do 302 redirects affect SEO?

If used correctly, a 302 redirect will not hurt your SEO efforts. When you choose this type of redirect, the original page remains indexed in Google and no value (link equity) is transferred to the new URL because Google knows that this is only temporary.

What is a redirect URL example?

A redirect is when a web page is visited at a certain URL, it changes to a different URL. For example, a person visits âwebsite.com/page-aâ in their browser and they are redirected to âwebsite.com/page-bâ instead.

What should I use for a redirect URL? A redirect is a way of sending both users and search engines to a different URL than the one they originally requested. The three most commonly used redirects are 301, 302 and Meta Refresh.

What does redirect URL means?

URL redirection, also called URL forwarding, is a World Wide Web technique for making a web page available under more than one URL address. When a browser tries to open a redirected URL, a page with a different URL is opened.

How do we redirect by URL?

Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Select the desired domain, fill in the URL you want to redirect to another, and add the URL of the new page destination. When ready, click Create.

What does a redirect URL do?

URL Redirection (also called URL Forwarding) is a technique used to redirect your domain’s visitors to a different URL. You can forward your domain name to any website, web page, etc. that is available online. Redirects use status codes defined within the HTTP protocol.

How do I set a redirect URL?

Click the URL Redirects tab. At the top right, click Add URL Redirect. In the right pane, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.

How do I permanently redirect a URL?

To redirect a website permanently, use a 301 redirect. This type of redirect is best for SEO purposes and also informs the search engines that the site has moved constantly. If you change your domain name and want to point to a different URL, a 301 redirect is your best option.

How do I automatically redirect a website to another URL?

To redirect from an HTML page, use the META tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect later.

Does changing your URL affect SEO?

The impact of changing URLs on your SEO can be severe. Thus making your site susceptible to 404 errors and broken links, which means it’s nearly impossible for Google to properly index your site.

Does URL play a role in SEO? URLs are a good way to signal to a potential visitor what a page is about. The correct use of URLs can help improve click-through rates wherever the links are shared. And keeping URLs shorter makes them usable and easier to share. Web pages that make it easy to share help users popularize the pages.

Can I redirect URL without hosting?

If you happen to not have a hosting plan and you would like to redirect your domain to another domain, it can be easily done with Cloudflare.

Can you have a domain without a host? The short answer to the question is “no”. That is, if all you want is to reserve a domain name, you can easily do it by simply registering that domain. You don’t need a web host or a website or anything like that to get that name.

Can you make a URL redirect?

Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Select the desired domain, fill in the URL you want to redirect to another, and add the URL of the new page destination. When ready, click Create.

How do I automatically redirect a website to another URL?

To redirect from an HTML page, use the META tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect later.

How do I set a redirect URL?

Click the URL Redirects tab. At the top right, click Add URL Redirect. In the right pane, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.