URL Redirects For SEO: A Technical Guide

Posted by

Reroutes for SEO should be utilized correctly because they affect how sites are crawled and indexed by Google.

While many people think about redirects as a web detour indication, a lot more is taking place, and it’s remarkably satisfying to discover.

Keep checking out for a comprehensive summary of redirects and the proper application for technical SEO.

What Is A Redirect?

Site redirects tell web browsers and online search engine information about a URL and where to discover the web page.

A URL redirect involves code implemented to a specific URL, or a group of URLs so that the user (or search engine) is sent out to a different page to the real 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 use redirects are:

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

For SEO purposes, URL redirects are important since they:

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

Redirects can be implemented on a group or domain-wide basis but often need to be set on a specific basis to prevent issues.

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

Kinds of Redirects

There are 3 main types of redirects:

  • Meta Refresh redirects are set at the page level however are normally not advised for SEO functions. There are two types of meta redirect: delayed which is viewed as a momentary redirect, and immediate, which is viewed as a long-term redirect.
  • Javascript redirects are likewise set on the customer side’s page and can cause SEO problems. Google has mentioned a choice for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the very best technique for SEO functions– we covered in-depth listed below.

What Is A HTTP Response Status Code?

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

When a user representative tries to access a web page, what occurs is that the user agent makes a request, and the site server problems a reaction.

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

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

For instance, if the ask for a URL succeeds, the server will provide a response code of 200, which suggests the request for a URL succeeded.

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

HTTP Redirects

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

If the URL exists at a various URL (since it was moved), the server tells 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 type of a 301 or 302 reaction status code.

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

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

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

3XX Series Of Status Codes

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

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

These are the different type of redirects offered for usage:

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

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

Because GoogleBot utilizes the most recent variation of Chrome (called a headless web browser), it’s easy to inspect if a status code works by checking if Chrome acknowledges the status code with an internet browser compatibility list.

For SEO, one ought to stick to using the 301 and 302 reaction codes unless there is a specific reason to utilize 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 shows to a user representative that the URL (often referred to as a target resource or simply resource) was changed to another area which it should utilize the new URL for future demands.

As mentioned previously, there is more details also.

The 301 status code also recommends to the user agent:

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

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

“Note: For historic reasons, a user representative MAY alter the demand approach from POST to GET for the subsequent demand. If this habits is undesirable, the 308 (Permanent Redirect) status code can be used instead.”

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

Before making a modification, you need to beware when utilizing a 301 redirect. The 301 redirects need to only be utilized when the change to a brand-new URL is permanent.

The 301 status code need to not be used when the modification is temporary.

In addition, if you change your mind later on and go back to the old URL, the old URL may not rank any longer and may require time to regain the rankings.

So, the main point to keep in mind is that a 301 status code will be used when the modification is irreversible.

302: Found

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

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

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

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

The referral to “historical factors” might describe old or buggy user representatives that might change the demand technique.

307: Temporary Redirect

A 307 redirect implies the requested URL is temporarily moved, and the user agent ought to use the initial URL for future demands.

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 request used to ask for the original URL.

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

The Mozilla documents of the 307 status code describes it more plainly than the official paperwork.

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

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

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

302 Vs. 307

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

In all instances, they have the same syntax for writing redirect guidelines. They vary only with commands used in configuration files. For instance, a redirect on Apache will look like this:

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

(You can check out symlinks here.)

On Nginx servers, it will appear like this:

reword ^/ oldfolder// newfolder/ irreversible;

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. “rewrite.”

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

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

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

Make sure 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 official documents for more information about the RewriteEngine.

To understand the examples below, you might describe the table listed below on RegExp essentials.

* absolutely no or more times
+ Several times
. any single character
? Absolutely 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 Produce Redirects

How To Develop A Redirect For A Single URL

The most common and extensively used kind of redirect is when erasing pages or changing URLs.

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

The routine expression “^” suggests 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 likewise utilize (. *), i.e., ^/ old-page(. *), but 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 redirect/ old-page/.

The following URLs will match and be directed to a brand-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 utilize redirect in the following type:

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

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

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

Redirect All Except

Let’s state we have a lot 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 need the “all other than” rule here.

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

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

Directory Change

You can use the guideline listed below if you did a category restructuring and want to move whatever from the old directory site to the brand-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 ought to 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 utilized two guidelines: one case without any trailing slash at the end and the other one with a tracking slash.

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

Remove A Word From URL

Let’s state you have 100 URLs on your website with the city name “Chicago” and want to remove 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 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 fundamental part of SEO.

If missing out on, you might threaten your website with replicate content issues due to the fact that online search engine treat URLs with “www” and “non-www” variations as different pages with the very same content.

For that reason, you should guarantee you run the site only with one variation you select.

If you want to run your site with the “www” version, utilize 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] 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 pick to remove the slash rather of adding then you will need the other guideline listed below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to encourage website owners to use SSL, moving to HTTPS is among the typically utilized redirects that almost every website has.

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

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 variation redirect into one HTTPS redirect guideline.

Redirect From Old Domain To New

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

RewriteCond % ^ 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” since any page for historic reasons may have incoming links to both versions.

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

Dealing with redirects utilizing plugins may be somewhat 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 advise a free plugin called Redirection, which has lots of criteria to control redirect guidelines and many beneficial docs.

Redirect Best Practices

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

This case typically happens 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 treated as 404s.

If you have too many pages like this, you should consider developing stunning 404 pages and engaging users to browse additional or find something other than what they were searching for by displaying a search option.

It is highly advised by Google that redirected page material must be comparable to the old page. Otherwise, such a redirect might be thought about 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 must ensure to redirect users to the appropriate page of the mobile version.

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

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

If you have no mobile version for a page, you can prevent 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 utilizing a meta refresh tag like the example listed below:

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

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

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

4. Avoid Redirect Chains

This message shows when you have a wrong regular expression setup and ends up in a boundless loop.

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

page 1 is rerouted and chosen to redirect page 2 to page 1 again. As an outcome, 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 a limitless loop and produce the error shown above. Conclusion Knowing what

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


websites appropriately. It’s a core part of comprehending SEO. Numerous circumstances need accurate knowledge of redirects, such as moving a site to a brand-new domain or producing a short-lived holding page URL for a webpage 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 utilize a particular

type of redirect. More Resources: Included Image: