URL Redirects For SEO: A Technical Guide

Posted by

Reroutes for SEO ought to be used properly because they impact how sites are crawled and indexed by Google.

While the majority of people think about redirects as a web detour indication, much more is happening, and it’s surprisingly satisfying to discover.

Keep reading for a thorough overview of redirects and the correct application for technical SEO.

What Is A Redirect?

Website reroutes inform internet browsers and online search engine info about a URL and where to discover the website.

A URL redirect includes code carried out to a particular URL, or a group of URLs so that the user (or search engine) is sent out to a various page to the actual URL that was input or clicked.

A redirect can be set as a:

  • Momentary redirect: 302, 303, 307, 308.
  • Irreversible redirect: 301.

When To Use Redirects

The primary reasons to utilize redirects are:

  • An individual page or entire domain has actually been moved (URL altered).
  • To permit the use of URL shorteners or ‘quite URLs.’
  • Site migration (e.g., HTTP to HTTPS).

For SEO purposes, URL redirects are necessary since they:

  • Forward authority of any links pointing to a page that has moved or been deleted.
  • Avoid 404 page not found errors (although in some cases it is better to leave a 404).

Redirects can be carried out on a group or domain-wide basis but typically need to be set on a private basis to prevent issues.

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

Kinds of Redirects

There are three primary kinds of redirects:

  • Meta Refresh redirects are set at the page level however are normally not recommended for SEO purposes. There are two kinds of meta redirect: postponed which is viewed as a temporary redirect, and instant, which is viewed as a permanent redirect.
  • Javascript reroutes are also set on the customer side’s page and can trigger SEO concerns. Google has specified a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best technique for SEO functions– we covered in-depth below.

What Is A HTTP Reaction Status Code?

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

When a user agent attempts to access a website, what happens is that the user agent makes a demand, and the site server issues a response.

The response is called an HTTP reaction status code. It supplies a status for the ask for a URL.

In the scenario where a user agent like GoogleBot requests a URL, the server offers a reaction.

For example, if the ask for a URL achieves success, the server will supply a response code of 200, which indicates the ask for a URL succeeded.

So, when you think about a GoogleBot reaching a site and attempting to crawl it, what’s occurring is a series of demands and responses.

HTTP Reroutes

An HTTP redirect is a server action to ask for a URL.

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

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

The entire 3xx series of reaction codes communicate much info that can optionally be acted on by the user representative.

An example of an action that the user agent 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 request for the new URL rather.

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

3XX Series Of Status Codes

Redirects are more than simply the 2 status codes everybody is familiar with, the 301 and 302 response codes.

There are an overall of seven main 3xx action status codes.

These are the various type of redirects available for usage:

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

Some of the above status codes have not been around as long and might not be used. So, prior to utilizing any redirect code other than 301 or 302, make sure that the designated user agent can interpret it.

Since GoogleBot utilizes the current variation of Chrome (called a headless web browser), it’s simple to examine if a status code is compatible by inspecting if Chrome recognizes the status code with a browser compatibility list.

For SEO, one ought to adhere to utilizing the 301 and 302 reaction codes unless there is a specific factor to use among the other codes.

301: Moved Permanently

The 301 status code is routinely referenced as the 301 redirects. However the main name is 301 Moved Completely.

The 301 redirect suggests to a user agent that the URL (sometimes referred to as a target resource or merely resource) was altered to another area and that it must use the new URL for future demands.

As pointed out previously, there is more information too.

The 301 status code also suggests to the user representative:

  • Future requests for the URL ought to be made with the brand-new URL.
  • Whoever is making the demand should upgrade their links to the brand-new URL.
  • Subsequent demands can be changed from GET to POST.

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

“Keep in mind: For historical reasons, a user agent MAY change the request approach from POST to GET for the subsequent request. If this habits is undesired, the 308 (Permanent Redirect) status code can be utilized rather.”

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

Prior to making a change, you need to beware when using a 301 redirect. The 301 redirects should just be utilized when the modification to a new URL is long-term.

The 301 status code need to not be used when the modification is short-term.

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

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

302: Found

The main thing to comprehend about the 302 status code is that it’s useful for scenarios where a URL is temporarily changed.

The meaning of this response code is that the URL is briefly at a different URL, and it is recommended to utilize the old URL for future demands.

The 302 redirect status code likewise features a technical caution related to GET and Post:

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

The reference to “historical factors” may refer to old or buggy user agents that might change the demand technique.

307: Temporary Redirect

A 307 redirect indicates the requested URL is momentarily moved, and the user agent need to use the original URL for future demands.

The only difference in between a 302 and a 307 status code is that a user representative should request the brand-new URL with the same HTTP demand utilized to ask for the initial URL.

That indicates if the user agent demands the page with a GET request, then the user agent must use a GET ask for the new temporary URL and can not use the POST demand.

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 get the requested resource at another URI with exact same approach that was utilized in the previous demand.

This has the very same semantics as the 302 Found HTTP action code, with the exception that the user representative must not change the HTTP method used: if a POST was used in the first demand, a POST needs to be used in the 2nd demand.”

Other than the 307 status code needing subsequent demands to be of the same kind (POST or GET) and that the 302 can go in any case, whatever else is the very same between the 302 and the 307 status codes.

302 Vs. 307

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

In all circumstances, they have the very same syntax for writing redirect rules. They differ just with commands utilized in setup 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:

rewrite ^/ oldfolder// newfolder/ long-term;

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

For instance:

  • Servers status code of redirect: “301 ″ vs. “long-term.”
  • Action command: “RedirectMatch” vs. “reword.”

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

On Apache, make sure that mod_rewrite and mod_alias modules (responsible for dealing with 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.

Ensure that the.htaccess file has these 2 lines above the redirect guidelines and put the rules below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the main documents for more information about the RewriteEngine.

To comprehend the examples below, you may refer to the table listed below on RegExp essentials.

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

How To Produce Redirects

How To Develop A Redirect For A Single URL

The most typical and extensively utilized kind of redirect is when erasing pages or changing URLs.

For example, say 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 in between the two methods is that the first uses the Apache mod_rewrite module, and the second usages mod_alias. It can be done using both approaches.

The routine expression “^” means the URL must begin with “/ old-page” while (/? |/. *)$ indicates that anything that follows “/ old-page/” with a slash “/” or without an exact match needs to be rerouted to/ new-page/.

We might also use (. *), i.e., ^/ old-page(. *), but the issue is, if you have another page with a comparable URL like/ old-page-other/, it will likewise be rerouted when we only wish to reroute/ 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 use reroute in the following kind:

Redirect 301/ old-page// new-page/

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

Even/ old-page without a routing slash “/” would end up as a 404.

Redirect All Except

Let’s say we have a lot 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 except” guideline here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to reroute all under/ classification/ on the third line except if it is/ category/final-subcategory/ on the fourth line. We likewise have the “!-f” guideline on the 2nd line, neglecting 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 an image break.

Directory site Change

You can use the rule listed below if you did a classification restructuring and wish to move everything from the old directory site to the new one.

RewriteRule ^ old-directory$/ new-directory/ [R=301, NC, L] RewriteRule ^ old-directory/(. *)$/ new-directory/$1 [R=301, NC, L] I utilized $1 in the target to inform the server that it should remember everything in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the location. As an outcome, it will be rerouted to/ new-directory/subdirectory/.

I used 2 guidelines: one case without any trailing slash at the end and the other one with a trailing slash.

I could combine them into one guideline utilizing (/? |. *)$ RegExp at the end, but it would cause issues and include a “//” slash to the end of the URL when the asked for URL without any trailing slash has a question string (i.e., “/ old-directory? utm_source=facebook” would be rerouted to “/ new-directory//? utm_source=facebook”).

Eliminate 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://% SERVER_NAME/$1-$2 [NC, R=301, L] If the example URL is in the type 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 site with duplicate content concerns because search engines deal with URLs with “www” and “non-www” versions as different pages with the same material.

For that reason, you need to guarantee you run the website only with one variation you pick.

If you want to run your website with the “www” version, utilize this guideline:

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” version: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is likewise part of canonicalization considering that URLs with a slash at the end or without are likewise treated differently. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is redirected to/ example-page/. You might select to eliminate the slash rather of including then you will need the other rule below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

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

The rewrite rule below can be utilized to force HTTPS on every site.

RewriteCond % HTTP_HOST ^ 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 combine a www or non-www version redirect into one HTTPS redirect rule.

Redirect From Old Domain To New

This is also one of the most pre-owned redirects when you choose to rebrand and require to alter your domain. The rule listed below reroutes old-domain. com to new-domain. com.

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

Most site owners use WordPress and may not require a.htaccess declare redirects but utilize a plugin rather.

Handling redirects using plugins may be slightly various from what we talked about above. You may need to read their documents to manage RegExp correctly for the particular plugin.

From the existing ones, I would recommend a free plugin called Redirection, which has many specifications to manage redirect guidelines and many beneficial docs.

Redirect Finest Practices

1. Do not Reroute All 404 Broken URLs To The Homepage

This case often occurs when you are too lazy to investigate your 404 URLs and map them to the proper landing page.

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

If you have too many pages like this, you ought to think about creating gorgeous 404 pages and engaging users to search additional or discover something besides what they were looking for by displaying a search choice.

It is highly advised by Google that rerouted page material ought to be equivalent to the old page. Otherwise, such a redirect may be thought about a soft 404, and you will lose the rank of that page.

2. Get Mobile Page-Specific Reroutes Right

If you have different URLs for desktop and mobile sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you need to make sure to reroute users to the proper page of the mobile variation.

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

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

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

3. How To Use Meta Refresh

It is possible to do a redirect using a meta revitalize tag like the example listed 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 recommend using it.

According to John Mueller, search engines may not be able to recognize that kind of redirect correctly. The very same is also true about JavaScript reroutes.

4. Avoid Redirect Chains

This message shows when you have an incorrect routine expression setup and winds up in an infinite loop.

Screenshot by author, December 2022 Normally, this takes place when you have a redirect chain. Let’s say you rerouted page 1 to page 2 a very long time earlier. You might have forgotten that

page 1 is redirected and decided to redirect page 2 to page 1 once again. As a result, you will end up with a guideline like this: RewriteRule ^ page1/ page2 [R

=301, NC, L] RewriteRule ^ page2/ page1 [R=301, NC, L] This will create an unlimited loop and produce the mistake shown above. Conclusion Understanding what

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


websites effectively. It’s a core part of comprehending SEO. Numerous scenarios require precise understanding of redirects, such as moving a website to a new domain or creating a temporary holding page URL for a webpage that will return under its typical URL. While so much is possible with a plugin, plugins can be misused without correctly understanding when and why to use a specific

sort of redirect. More Resources: Featured Image: