URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO needs to be utilized correctly because they affect how websites are crawled and indexed by Google.

While the majority of people consider redirects as an internet detour indication, far more is taking place, and it’s surprisingly pleasurable to find.

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

What Is A Redirect?

Website reroutes inform browsers and online search engine info about a URL and where to find the webpage.

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.
  • Permanent redirect: 301.

When To Utilize Redirects

The primary reasons to utilize redirects are:

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

For SEO functions, URL redirects are necessary since they:

  • Forward authority of any links indicating a page that has moved or been deleted.
  • Prevent 404 page not discovered mistakes (although sometimes 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 an individual basis to avoid concerns.

When utilizing RegEX for group redirects, it can have unforeseen results if your reasoning isn’t flawless!

Types Of Redirects

There are three primary kinds of redirects:

  • Meta Refresh redirects are set at the page level however are normally not suggested for SEO functions. There are two types of meta redirect: delayed which is seen as a short-term redirect, and instant, which is seen as an irreversible redirect.
  • Javascript reroutes are likewise set on the customer side’s page and can trigger SEO problems. Google has stated a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best approach for SEO purposes– we covered extensive listed below.

What Is A HTTP Reaction Status Code?

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

When a user agent tries to access a website, what takes place is that the user agent makes a demand, and the site server issues a reaction.

The action is called an HTTP response status code. It provides a status for the ask for a URL.

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

For example, if the request for a URL achieves success, the server will provide an action code of 200, which indicates the ask for a URL succeeded.

So, when you consider a GoogleBot reaching a website and attempting to crawl it, what’s occurring is a series of demands and reactions.

HTTP Reroutes

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

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

The action code for a changed URL is typically in the kind of a 301 or 302 response status code.

The whole 3xx series of response codes interact much details that can optionally be acted upon by the user agent.

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 requested, it will ask for the brand-new URL rather.

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

3XX Series Of Status Codes

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

There are a total of 7 main 3xx response status codes.

These are the different sort of redirects offered for use:

  • 300 Several Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Short-term Redirect.
  • 308 Permanent Redirect.

Some of the above status codes have not been around as long and may not be used. So, prior to utilizing any redirect code aside from 301 or 302, make certain that the desired user representative can interpret it.

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

For SEO, one should stay with utilizing the 301 and 302 response codes unless there is a particular factor to utilize one of the other codes.

301: Moved Permanently

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

The 301 redirect indicates to a user agent that the URL (in some cases referred to as a target resource or merely resource) was changed to another location and that it need to utilize the new URL for future requests.

As discussed previously, there is more info too.

The 301 status code likewise suggests to the user representative:

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

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

“Keep in mind: For historical factors, a user agent MAY change the request technique from POST to GET for the subsequent request. If this behavior is unwanted, the 308 (Long-term Redirect) status code can be used 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 must take care when using a 301 redirect. The 301 redirects need to just be utilized when the change to a brand-new URL is permanent.

The 301 status code should not be used when the change is short-lived.

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

So, the main point to keep in mind is that a 301 status code will be used when the change is long-term.

302: Found

The main thing to comprehend about the 302 status code is that it works for situations where a URL is temporarily altered.

The meaning of this reaction code is that the URL is momentarily at a various URL, and it is suggested to use the old URL for future requests.

The 302 redirect status code also includes a technical caution related to GET and Post:

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

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

307: Temporary Redirect

A 307 redirect indicates the asked for URL is temporarily moved, and the user agent should use the initial URL for future requests.

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

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

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

“The server sends this action to direct the customer to get the requested resource at another URI with exact same approach that was utilized in the prior demand.

This has the exact same semantics as the 302 Found HTTP action code, with the exception that the user representative need to not alter the HTTP technique utilized: if a POST was used in the very first demand, a POST needs to be used in the second request.”

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

302 Vs. 307

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

In all instances, they have the very same syntax for composing redirect guidelines. They differ only with commands utilized in configuration files. For instance, a redirect on Apache will appear like this:

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

(You can read about symlinks here.)

On Nginx servers, it will look like this:

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

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

For example:

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

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

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

Since the most widely spread server type is Apache, here are examples for.htaccess apache files.

Make certain that the.htaccess file has these 2 lines above the redirect guidelines and put the guidelines listed below them:

Choices +FollowSymlinks RewriteEngine on

Read the main paperwork to find out more about the RewriteEngine.

To understand the examples listed below, you might describe the table listed 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) 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 common and widely utilized kind of redirect is when erasing pages or changing URLs.

For instance, say you changed 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 distinction in between the two approaches is that the very first utilizes the Apache mod_rewrite module, and the second uses mod_alias. It can be done utilizing both approaches.

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

We could likewise 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 rerouted when we just 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 redirect any variation of the page URL to a brand-new one. If we use reroute in the following form:

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

Without regular expressions, all URLs with UTM query string, e.g.,/ old-page? utm_source=facebook.com (which prevails given 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 wind up as a 404.

Redirect All Except

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

RewriteCond % !/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we want to redirect all under/ classification/ on the third line other than if it is/ category/final-subcategory/ on the 4th line. We likewise have the “!-f” rule on the 2nd line, disregarding any file like images, CSS, or JavaScript files.

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

Directory site Change

You can utilize the guideline 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 used $1 in the target to tell the server that it need to 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 2 guidelines: one case with no tracking slash at the end and the other one with a trailing slash.

I could combine them into one rule using (/? |. *)$ RegExp at the end, but it would trigger issues and include a “//” slash to the end of the URL when the requested URL with no 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 say 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 remains in the type 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, you might endanger your site with replicate content issues due to the fact that online search engine treat URLs with “www” and “non-www” versions as various pages with the very same material.

For that reason, you should ensure you run the site only with one variation you choose.

If you want to run your site 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 % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Routing slash is likewise part of canonicalization since 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 rerouted to/ example-page/. You might pick to remove the slash rather of including then you will require the other guideline below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to encourage website owners to utilize SSL, moving to HTTPS is among the typically used redirects that almost every website has.

The reword guideline below can be used to require HTTPS on every website.

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

Redirect From Old Domain To New

This is also among the most pre-owned redirects when you choose to rebrand and need to change your domain. The rule listed below reroutes 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 uses two cases: one with the “www” version of URLs and another “non-www” since any page for historical reasons may have incoming links to both variations.

Most website owners use WordPress and might not need a.htaccess apply for redirects but utilize a plugin instead.

Handling redirects utilizing plugins may be slightly various from what we went over above. You may require to read their documentation to deal with RegExp correctly for the particular plugin.

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

Redirect Finest Practices

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

This case frequently takes place 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 a lot of pages like this, you must consider producing stunning 404 pages and engaging users to browse more or find something besides what they were looking for by displaying a search option.

It is highly advised by Google that redirected page content ought to be comparable 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 various URLs for desktop and mobile sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you should make sure to redirect users to the suitable page of the mobile variation.

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

Likewise, you need to ensure that if one page is 404 on the desktop, it needs to also be 404 on mobile.

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

3. How To Utilize Meta Refresh

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

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

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

According to John Mueller, search engines might not be able to recognize that kind of redirect correctly. The very same is likewise real about JavaScript redirects.

4. Avoid Redirect Chains

This message displays when you have a wrong regular expression setup and winds up in an infinite loop.

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

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

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

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


websites properly. It’s a core part of understanding SEO. Many circumstances require precise understanding of redirects, such as migrating a site to a new domain or creating a short-term holding page URL for a website that will return under its normal URL. While a lot is possible with a plugin, plugins can be misused without effectively comprehending when and why to utilize a specific

kind of redirect. More Resources: Featured Image: