URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO should be used properly since they impact how websites are crawled and indexed by Google.

While the majority of people think about redirects as a web detour indication, a lot more is taking place, and it’s surprisingly satisfying to find.

Keep reading for an extensive overview of redirects and the appropriate application for technical SEO.

What Is A Redirect?

Site reroutes tell internet browsers and search engines information about a URL and where to discover the webpage.

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

A redirect can be set as a:

  • Short-term redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Use Redirects

The main reasons to utilize redirects are:

  • A private page or whole domain has actually been moved (URL altered).
  • To enable the usage of URL shorteners or ‘quite URLs.’
  • Website migration (e.g., HTTP to HTTPS).

For SEO purposes, URL redirects are important because they:

  • Forward authority of any links indicating a page that has moved or been deleted.
  • Avoid 404 page not discovered mistakes (although sometimes it is better to leave a 404).

Redirects can be implemented on a group or domain-wide basis but often require to be set on an individual basis to prevent concerns.

When using RegEX for group reroutes, it can have unforeseen results if your reasoning isn’t perfect!

Kinds of Redirects

There are three primary kinds of redirects:

  • Meta Refresh redirects are set at the page level but are normally not suggested for SEO purposes. There are 2 kinds of meta redirect: postponed which is seen as a short-term redirect, and instant, which is seen as a long-term redirect.
  • Javascript redirects are likewise set on the client side’s page and can cause SEO problems. Google has actually specified a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the very best method for SEO functions– we covered thorough listed below.

What Is A HTTP Action Status Code?

Web browsers and search engine spiders like GoogleBot are called user agents.

When a user agent attempts to access a web page, what takes place is that the user representative makes a request, and the site server issues a response.

The action is called an HTTP action status code. It supplies a status for the request for a URL.

In the circumstance where a user representative like GoogleBot requests a URL, the server offers a response.

For instance, if the request for a URL achieves success, the server will provide a response code of 200, which suggests the request for a URL achieved success.

So, when you think of a GoogleBot reaching a website and trying to crawl it, what’s taking place is a series of demands and reactions.

HTTP Redirects

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

If the URL exists at a different URL (due to the fact that it was moved), the server informs the user agent that the URL request is being redirected to a different URL.

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

The entire 3xx series of reaction codes communicate much details that can additionally be acted upon by the user agent.

An example of an action that the user representative can take is to conserve a cache of the brand-new URL so that the next time the old URL is asked for, it will ask for the brand-new URL rather.

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

3XX Series Of Status Codes

Redirects are more than simply the 2 status codes everyone recognizes with, the 301 and 302 action codes.

There are an overall of 7 main 3xx reaction status codes.

These are the various kinds of redirects readily available for usage:

  • 300 Numerous Choices.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Long-term Redirect.

Some of the above status codes have actually not been around as long and might not be utilized. So, before utilizing any redirect code besides 301 or 302, be sure that the intended user agent can analyze it.

Because GoogleBot utilizes the current version of Chrome (called a headless internet browser), it’s simple to check if a status code works by inspecting if Chrome acknowledges the status code with a web browser compatibility list.

For SEO, one must stick to using the 301 and 302 reaction codes unless there is a particular factor to use among the other codes.

301: Moved Permanently

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

The 301 redirect suggests to a user agent that the URL (often referred to as a target resource or simply resource) was altered to another area which it ought to use the new URL for future requests.

As discussed previously, there is more info as well.

The 301 status code also recommends to the user agent:

  • Future ask for the URL ought to be made with the new URL.
  • Whoever is making the request must update their links to the new URL.
  • Subsequent requests can be changed from GET to POST.

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

“Keep in mind: For historical reasons, a user representative MAY alter the demand technique from POST to GET for the subsequent demand. If this behavior is undesired, the 308 (Permanent Redirect) status code can be utilized instead.”

For SEO, when search engines see a 301 redirect, they pass the old page’s ranking to the new one.

Before making a modification, you need to be careful when utilizing a 301 redirect. The 301 redirects should just be used when the change to a new URL is irreversible.

The 301 status code should not be utilized when the change is short-term.

Furthermore, if you change your mind later and return to the old URL, the old URL might not rank any longer and might take some time to regain the rankings.

So, the main point to keep in mind 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 works for scenarios where a URL is momentarily altered.

The significance of this action code is that the URL is momentarily at a different URL, and it is suggested to utilize the old URL for future requests.

The 302 redirect status code likewise includes a technical caution associated to GET and Post:

“Note: For historical factors, a user representative MAY alter the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used rather.”

The reference to “historic factors” might describe old or buggy user representatives that may alter the request approach.

307: Temporary Redirect

A 307 redirect indicates the asked for URL is briefly moved, and the user representative must use the initial URL for future requests.

The only distinction in between a 302 and a 307 status code is that a user agent must ask for the new URL with the very same HTTP demand utilized to request the original URL.

That suggests if the user agent requests the page with a GET request, then the user representative must utilize a GET request for the brand-new short-term URL and can not use the POST demand.

The Mozilla documents of the 307 status code explains it more plainly than the main paperwork.

“The server sends this response to direct the client to get the asked for resource at another URI with very same technique that was used in the prior demand.

This has the very same semantics as the 302 Found HTTP reaction code, with the exception that the user representative should not alter the HTTP approach utilized: if a POST was used in the very first request, a POST must be utilized in the second demand.”

Aside from the 307 status code requiring subsequent requests to be of the exact same kind (POST or GET) and that the 302 can go either way, whatever else is the very same in between the 302 and the 307 status codes.

302 Vs. 307

You may handle a redirect via server config files.htaccess on Apache, example.conf file on Nginx or via plugins if you are utilizing WordPress.

In all circumstances, they have the exact same syntax for composing redirect guidelines. They differ only with commands used in configuration files. For example, a redirect on Apache will look like this:

Alternatives +FollowSymlinks RewriteEngine on RedirectMatch 301 ^/ oldfolder// newfolder/

(You can read about symlinks here.)

On Nginx servers, it will appear like this:

reword ^/ oldfolder// newfolder/ irreversible;

The commands utilized to inform the server’s status code of redirect and the action command vary.

For example:

  • Servers status code of redirect: “301 ″ vs. “irreversible.”
  • Action command: “RedirectMatch” vs. “rewrite.”

However the redirect syntax (^/ oldfolder// newfolder/) is the very same for both.

On Apache, ensure that mod_rewrite and mod_alias modules (responsible for handling redirects) are made it possible for on your server.

Because the most commonly spread out server type is Apache, here are examples for.htaccess apache files.

Make sure that the.htaccess file has these two lines above the redirect rules and put the guidelines listed below them:

Choices +FollowSymlinks RewriteEngine on

Read the main documents to get more information about the RewriteEngine.

To comprehend the examples listed below, you might describe the table listed below on RegExp fundamentals.

* absolutely no or more times
+ Several times
. any single character
? No or one time
^ Start of the string
$ End of the string
| b OR operadn” |” a or b
(z) keeps in mind the match to be utilized when calling $1

How To Develop Redirects

How To Produce A Redirect For A Single URL

The most typical and extensively utilized type of redirect is when erasing pages or altering URLs.

For instance, state you altered the URL from/ old-page/ to/ new-page/. The redirect rule would be:

RewriteRule ^ old-page(/? |/. *)$/ new-page/ [R=301, L] Or RedirectMatch 301 ^/ old-page(/? |/. *)$/ new-page/

The only difference between the two methods is that the very first utilizes the Apache mod_rewrite module, and the 2nd usages mod_alias. It can be done utilizing both approaches.

The regular expression “^” implies the URL must start with “/ old-page” while (/? |/. *)$ suggests that anything that follows “/ old-page/” with a slash “/” or without a specific match should be redirected to/ new-page/.

We might likewise utilize (. *), i.e., ^/ old-page(. *), but the problem is, if you have another page with a comparable URL like/ old-page-other/, it will likewise be rerouted when we only wish to redirect/ old-page/.

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

/ old-page/ / new-page/
/ old-page / new-page/
/ old-page/? utm_source=facebook.com / new-page/? utm_source=facebook.com
/ old-page/child-page/ / new-page/

It will reroute any variation of the page URL to a brand-new one. If we utilize reroute in the following form:

Reroute 301/ old-page// new-page/

Without regular expressions, all URLs with UTM inquiry string, e.g.,/ old-page? utm_source=facebook.com (which is common considering that URLs are used to be shared over a social media), would end up as 404s.

Even/ old-page without a trailing slash “/” would wind up as a 404.

Redirect All Other than

Let’s say we have a bunch of URLs like/ category/old-subcategory -1/,/ category/old-subcategory -2/,/ category/final-subcategory/ and want to combine all subcategories into/ category/final-subcategory/. We require the “all other than” guideline here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we wish to redirect all under/ category/ on the third line except if it is/ category/final-subcategory/ on the fourth line. We also have the “!-f” guideline on the second line, disregarding any file like images, CSS, or JavaScript files.

Otherwise, if we have some possessions like “/ category/image. jpg,” it will likewise be redirected to “/ final-subcategory/” and trigger an image break.

Directory Modification

You can utilize the rule listed below if you did a classification restructuring and want to move whatever from the old directory to the new one.

RewriteRule ^ old-directory$/ new-directory/ [R=301, NC, L] RewriteRule ^ old-directory/(. *)$/ new-directory/$1 [R=301, NC, L] I used $1 in the target to inform the server that it must keep in mind whatever in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the destination. As a result, it will be rerouted to/ new-directory/subdirectory/.

I utilized 2 rules: one case without any routing slash at the end and the other one with a trailing slash.

I could combine them into one guideline using (/? |. *)$ RegExp at the end, however it would cause problems and add a “//” slash to the end of the URL when the requested URL with no tracking slash has an inquiry string (i.e., “/ old-directory? utm_source=facebook” would be redirected to “/ new-directory//? utm_source=facebook”).

Remove A Word From URL

Let’s state you have 100 URLs on your site with the city name “Chicago” and wish to eliminate them.

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

RewriteRule ^(. *)-chicago-(. *) http://% /$1-$2 [NC, R=301, L] If the example URL remains in the kind http://yourwebiste.com/example/chicago/event/, then the redirect would be: RewriteRule ^(. *)/ chicago/(. *) http://% SERVER_NAME/$1/$2 [NC, R=301, L] Set A Canonical URL

Having canonical URLs is the most vital part of SEO.

If missing, you might threaten your website with replicate content issues since online search engine treat URLs with “www” and “non-www” variations as different pages with the exact same material.

Therefore, you must guarantee you run the site only with one variation you select.

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

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” variation: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is also part of canonicalization considering that URLs with a slash at the end or without are also treated in a different way. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is redirected to/ example-page/. You may select to get rid of the slash instead of adding then you will need the other rule listed below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to motivate site owners to use SSL, migrating to HTTPS is one of the frequently used redirects that nearly every website has.

The rewrite rule below can be used to require HTTPS on every site.

RewriteCond % ^ yourwebsite.com [NC, OR] RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ https://www.yourwebsite.com/$1 [L, R=301, NC] Utilizing this, you can integrate a www or non-www variation redirect into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is likewise among the most secondhand redirects when you decide to rebrand and require to change your domain. The rule listed below redirects old-domain. com to new-domain. com.

RewriteCond % ^ old-domain. com$ [OR] RewriteCond % ^ www.old-domain.com$ RewriteRule (. *)$ http://www.new-domain.com/$1 [R=301, L] It utilizes two cases: one with the “www” variation of URLs and another “non-www” due to the fact that any page for historical factors may have incoming links to both versions.

A lot of website owners utilize WordPress and may not need a.htaccess file for redirects however use a plugin instead.

Managing redirects utilizing plugins might be a little various from what we went over above. You might need to read their documentation to manage RegExp properly for the particular plugin.

From the existing ones, I would recommend a totally free plugin called Redirection, which has lots of criteria to manage redirect guidelines and numerous useful docs.

Redirect Best Practices

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

This case typically happens when you are too lazy to examine your 404 URLs and map them to the proper landing page.

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

If you have too many pages like this, you must consider creating stunning 404 pages and engaging users to search more or discover something besides what they were looking for by displaying a search option.

It is strongly recommended by Google that rerouted page material should be comparable to the old page. Otherwise, such a redirect might 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 websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you must ensure to redirect users to the proper page of the mobile variation.

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

Also, you need to guarantee that if one page is 404 on the desktop, it needs to likewise be 404 on mobile.

If you have no mobile version for a page, you can avoid rerouting to the mobile variation and keep them on the desktop page.

3. How To Utilize Meta Refresh

It is possible to do a redirect using a meta revitalize tag like the example below:

If you insert this tag in/ old-page/, it will reroute the user instantly to/ new-page/.

Google does not restrict this redirect, but it does not advise utilizing it.

According to John Mueller, online search engine might not have the ability to recognize that type of redirect properly. The same is likewise real about JavaScript reroutes.

4. Avoid Redirect Chains

This message shows when you have a wrong routine expression setup and ends up in an unlimited loop.

Screenshot by author, December 2022 Usually, this occurs when you have a redirect chain. Let’s say you redirected page 1 to page 2 a long time earlier. You may have forgotten that

page 1 is redirected and chosen to reroute page 2 to page 1 once again. As an outcome, you will wind up with a guideline like this: RewriteRule ^ page1/ page2 [R

=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will produce a limitless loop and produce the mistake revealed above. Conclusion Knowing what

redirects are and which situation needs a specific status code is fundamental to


websites correctly. It’s a core part of understanding SEO. Lots of circumstances need accurate knowledge of redirects, such as moving a website to a new domain or developing a temporary holding page URL for a website that will return under its regular URL. While a lot is possible with a plugin, plugins can be misused without properly understanding when and why to use a specific

sort of redirect. More Resources: Included Image: