URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO ought to be utilized properly because they impact how websites are crawled and indexed by Google.

While most people think about redirects as an internet detour indication, a lot more is happening, and it’s surprisingly enjoyable to find.

Keep reading for a comprehensive introduction of redirects and the appropriate application for technical SEO.

What Is A Redirect?

Website reroutes tell web browsers and online search engine details about a URL and where to discover the website.

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

A redirect can be set as a:

  • Temporary redirect: 302, 303, 307, 308.
  • Long-term redirect: 301.

When To Utilize Redirects

The primary reasons to utilize redirects are:

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

For SEO purposes, URL redirects are essential since they:

  • Forward authority of any links indicating a page that has moved or been erased.
  • Prevent 404 page not discovered mistakes (although often it is much 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 utilizing RegEX for group redirects, it can have unforeseen results if your logic isn’t perfect!

Kinds of Redirects

There are 3 main types of redirects:

  • Meta Refresh redirects are set at the page level but are generally not suggested for SEO functions. There are 2 kinds of meta redirect: delayed which is viewed as a short-term redirect, and instant, which is seen as an irreversible redirect.
  • Javascript redirects are also set on the customer side’s page and can cause SEO issues. Google has mentioned a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best technique for SEO functions– we covered thorough listed below.

What Is A HTTP Reaction Status Code?

Browsers and search engine spiders like GoogleBot are called user representatives.

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

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

In the scenario where a user representative like GoogleBot demands a URL, the server offers an action.

For example, if the request for a URL achieves success, the server will offer a reaction code of 200, which means the ask for a URL succeeded.

So, when you think about a GoogleBot reaching a website and trying to crawl it, what’s happening is a series of requests and actions.

HTTP Redirects

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

If the URL exists at a different URL (because it was moved), the server tells the user representative that the URL request is being rerouted to a different URL.

The action code for an altered URL is generally in the kind of a 301 or 302 action status code.

The entire 3xx series of reaction codes interact much details that can optionally be acted upon by the user representative.

An example of an action that the user representative can take is to save a cache of the new URL so that the next time the old URL is asked for, it will request the new URL instead.

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

3XX Series Of Status Codes

Redirects are more than just the 2 status codes everybody recognizes with, the 301 and 302 reaction codes.

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

These are the different kinds of redirects offered for use:

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

A few of the above status codes have not been around as long and might not be used. So, prior to using any redirect code besides 301 or 302, make sure that the intended user representative can interpret it.

Since GoogleBot uses the most recent version of Chrome (called a headless web browser), it’s simple to inspect if a status code is compatible by examining if Chrome acknowledges the status code with a web browser compatibility list.

For SEO, one need to adhere to using the 301 and 302 reaction codes unless there is a specific reason to use among the other codes.

301: Moved Completely

The 301 status code is consistently referenced as the 301 redirects. However the official name is 301 Moved Permanently.

The 301 redirect shows to a user representative that the URL (in some cases described as a target resource or simply resource) was changed to another area and that it ought to use the brand-new URL for future requests.

As mentioned earlier, there is more information too.

The 301 status code likewise recommends to the user representative:

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

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

“Keep in mind: For historic factors, a user agent MAY change the request technique from POST to GET for the subsequent request. If this habits is undesirable, 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 modification, you need to be careful when utilizing a 301 redirect. The 301 redirects should just be utilized when the change to a new URL is long-term.

The 301 status code need to not be utilized when the change is temporary.

Additionally, if you alter your mind later on and go back to the old URL, the old URL might not rank anymore and might require time to regain the rankings.

So, the main thing to bear in mind is that a 301 status code will be utilized when the modification 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 changed.

The significance of this action code is that the URL is temporarily at a various URL, and it is suggested to use the old URL for future demands.

The 302 redirect status code also comes with a technical caution associated to GET and Post:

“Keep in mind: For historic factors, a user representative MAY change the demand approach from POST to GET for the subsequent request. If this habits is undesirable, the 307 (Short-term Redirect) status code can be utilized instead.”

The reference to “historical reasons” may refer to old or buggy user agents that might alter the demand method.

307: Temporary Redirect

A 307 redirect suggests the asked for URL is temporarily moved, and the user representative must utilize the initial URL for future requests.

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

That means if the user representative demands the page with a GET request, then the user agent need to use a GET ask for the brand-new temporary URL and can not use the POST request.

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

“The server sends this reaction to direct the client to get the requested resource at another URI with same approach that was utilized in the previous request.

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

Other than the 307 status code requiring subsequent requests to be of the very same kind (POST or GET) which the 302 can go in either case, everything else is the exact same between the 302 and the 307 status codes.

302 Vs. 307

You might deal with a redirect by means of server config files.htaccess on Apache, example.conf file on Nginx or by means of plugins if you are using WordPress.

In all circumstances, they have the very same syntax for composing redirect rules. They vary only with commands utilized in setup files. For example, a redirect on Apache will appear like this:

Choices +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 example:

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

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

On Apache, guarantee that mod_rewrite and mod_alias modules (accountable for handling redirects) are allowed on your server.

Given that the most commonly spread 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 rules listed below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the main documents to learn more about the RewriteEngine.

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

* zero 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) remembers the match to be used when calling $1

How To Develop Redirects

How To Develop A Redirect For A Single URL

The most common and widely 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 guideline would be:

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

The only difference between the two approaches is that the first utilizes the Apache mod_rewrite module, and the second usages mod_alias. It can be done using both approaches.

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

We might also use (. *), i.e., ^/ old-page(. *), however the issue is, if you have another page with a similar URL like/ old-page-other/, it will likewise be rerouted when we just want 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 redirect any variation of the page URL to a new one. If we use 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 given that URLs are utilized to be shared over a social network), would end up as 404s.

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

Redirect All Except

Let’s state 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 need the “all except” rule here.

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

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

Directory Change

You can utilize the guideline listed below if you did a category restructuring and want to move everything 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 utilized $1 in the target to tell the server that it must remember everything in the URL that follows/ old-directory/ (i.e.,/ old-directory/subdirectory/) and pass it (i.e., “/ subdirectory/”) onto the destination. As an outcome, it will be redirected to/ new-directory/subdirectory/.

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

I could integrate them into one rule utilizing (/? |. *)$ RegExp at the end, but it would trigger problems and add a “//” slash to the end of the URL when the asked for URL without any trailing slash has an inquiry string (i.e., “/ old-directory? utm_source=facebook” would be redirected to “/ new-directory//? utm_source=facebook”).

Eliminate A Word From URL

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

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

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

Having canonical URLs is the most important part of SEO.

If missing out on, you may endanger your website with replicate content issues due to the fact that search engines treat URLs with “www” and “non-www” variations as various pages with the very same material.

For that reason, you must ensure you run the website only with one version you select.

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

RewriteCond % ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” variation: RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Tracking slash is also part of canonicalization because URLs with a slash at the end or without are likewise dealt with in a different way. 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 remove the slash instead of adding then you will require the other rule below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to encourage website owners to utilize SSL, moving to HTTPS is one of the typically used redirects that practically every website has.

The reword rule listed below can be utilized to force 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 version redirect into one HTTPS redirect guideline.

Redirect From Old Domain To New

This is likewise among the most used redirects when you choose to rebrand and need 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” version of URLs and another “non-www” due to the fact that any page for historic reasons might have inbound links to both variations.

Many site owners utilize WordPress and may not need a.htaccess file for redirects but utilize a plugin instead.

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

From the existing ones, I would advise a free plugin called Redirection, which has many criteria to control redirect guidelines and numerous beneficial docs.

Reroute Best Practices

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

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

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

If you have too many pages like this, you must consider developing gorgeous 404 pages and engaging users to search additional or discover something besides what they were trying to find by showing a search choice.

It is strongly recommended by Google that redirected page material need to be comparable to the old page. Otherwise, such a redirect may 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 (i.e., “example.com” for desktop and “m.example.com” for mobile), you ought to make certain to reroute users to the suitable page of the mobile version.

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

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

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

3. How To Use Meta Refresh

It is possible to do a redirect utilizing a meta refresh tag like the example below:

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

Google does not restrict this redirect, however it doesn’t suggest utilizing it.

According to John Mueller, online search engine may not be able to acknowledge that type of redirect properly. The same is likewise real about JavaScript redirects.

4. Prevent Redirect Chains

This message displays when you have a wrong regular expression setup and winds up in a boundless 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 might have forgotten that

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

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

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


webpages correctly. It’s a core part of understanding SEO. Many situations require accurate knowledge of redirects, such as moving a website to a new domain or producing a short-term holding page URL for a website that will return under its regular URL. While so much is possible with a plugin, plugins can be misused without correctly understanding when and why to use a specific

type of redirect. More Resources: Featured Image: