URL Redirects For SEO: A Technical Guide

Posted by

Redirects for SEO must be used correctly because they impact how sites are crawled and indexed by Google.

While many people think of redirects as a web detour indication, a lot more is occurring, and it’s remarkably enjoyable to discover.

Keep reading for a detailed summary of redirects and the correct application for technical SEO.

What Is A Redirect?

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

A URL redirect includes code carried out 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:

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

When To Utilize Redirects

The primary reasons to use redirects are:

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

For SEO purposes, URL redirects are necessary since they:

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

Redirects can be executed on a group or domain-wide basis however typically require to be set on a private basis to avoid concerns.

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

Types Of Redirects

There are 3 main types of redirects:

  • Meta Refresh redirects are set at the page level however are generally not suggested for SEO functions. There are two types of meta redirect: postponed which is seen as a momentary redirect, and instant, which is viewed as a long-term redirect.
  • Javascript reroutes are likewise set on the client side’s page and can cause SEO concerns. Google has specified a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the best technique for SEO purposes– we covered thorough below.

What Is A HTTP Reaction Status Code?

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

When a user representative tries to access a website, what occurs is that the user agent makes a demand, and the site server concerns a reaction.

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

In the situation where a user representative like GoogleBot requests a URL, the server provides an action.

For instance, if the request for a URL is successful, the server will supply an action code of 200, which means the request for a URL achieved success.

So, when you consider a GoogleBot reaching a website and trying to crawl it, what’s taking place 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 redirected to a different URL.

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

The whole 3xx series of reaction codes communicate much info that can optionally be acted on 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 requested, it will request the brand-new URL rather.

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 7 main 3xx action status codes.

These are the various kinds of redirects available for usage:

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

Some of the above status codes have not been around as long and might not be utilized. So, before using any redirect code aside from 301 or 302, make sure that the desired user representative can translate it.

Since GoogleBot uses the latest version of Chrome (called a headless internet browser), it’s simple to inspect if a status code works by examining if Chrome acknowledges the status code with a browser compatibility list.

For SEO, one should adhere 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 regularly referenced as the 301 redirects. But the main name is 301 Moved Permanently.

The 301 redirect indicates to a user representative that the URL (sometimes described as a target resource or just resource) was changed to another place and that it need to utilize the new URL for future requests.

As mentioned earlier, there is more info also.

The 301 status code also suggests to the user representative:

  • Future ask for the URL need to be made with the 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 concern. According to the official standards for the 301 status code:

“Note: For historic reasons, a user representative MAY change the request technique from POST to GET for the subsequent demand. If this habits is undesirable, 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 should be careful when utilizing a 301 redirect. The 301 redirects need to just be used when the modification to a new URL is permanent.

The 301 status code should not be used when the modification is momentary.

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

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

302: Found

The main point to understand about the 302 status code is that it works for situations where a URL is momentarily changed.

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

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

“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 unwanted, the 307 (Short-lived Redirect) status code can be utilized instead.”

The recommendation to “historical reasons” might describe old or buggy user agents that might alter the request approach.

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 demands.

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

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

The Mozilla paperwork of the 307 status code describes 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 same approach that was used in the previous request.

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

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

302 Vs. 307

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

In all instances, they have the 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:

Choices +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 utilized to inform the server’s status code of redirect and the action command vary.

For instance:

  • 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, ensure that mod_rewrite and mod_alias modules (accountable for handling redirects) are enabled on your server.

Considering that the most widely spread out 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 paperwork to read more about the RewriteEngine.

To comprehend the examples below, you might refer to the table below on RegExp basics.

* absolutely no or more times
+ One or more times
. any single character
? Absolutely 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 Create A Redirect For A Single URL

The most common and widely utilized kind of redirect is when deleting pages or altering URLs.

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

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

We could 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 also be rerouted when we just want 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 utilize reroute in the list below type:

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

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

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

Redirect All Other than

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 except” rule here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we want to reroute all under/ classification/ on the 3rd line other than if it is/ category/final-subcategory/ on the 4th line. We likewise have the “!-f” guideline on the second line, ignoring any file like images, CSS, or JavaScript files.

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

Directory Modification

You can utilize the guideline below if you did a category restructuring and wish to move everything 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 utilized $1 in the target to tell the server that it ought to keep in mind everything 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 guidelines: one case without any tracking slash at the end and the other one with a trailing slash.

I could integrate them into one rule utilizing (/? |. *)$ RegExp at the end, however it would cause issues and add a “//” slash to the end of the URL when the asked for 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”).

Get rid of A Word From URL

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

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

RewriteRule ^(. *)-chicago-(. *) http://% SERVER_NAME/$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 fundamental part of SEO.

If missing, you might threaten your site with duplicate content issues due to the fact that search engines treat URLs with “www” and “non-www” variations as various pages with the same material.

Therefore, you should ensure you run the website just with one variation you select.

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

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] Trailing slash is also part of canonicalization since 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 rerouted to/ example-page/. You may select to get rid of 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 motivate site owners to use SSL, moving to HTTPS is one of the typically utilized redirects that practically every website has.

The reword rule listed below can be utilized to require HTTPS on every site.

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC, OR] RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ https://www.yourwebsite.com/$1 [L, R=301, NC] Utilizing this, you can combine a www or non-www variation reroute 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 need to change your domain. The rule below redirects 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 two cases: one with the “www” version of URLs and another “non-www” because any page for historic reasons might have incoming links to both versions.

Many website owners use WordPress and might not require a.htaccess file for redirects but use a plugin instead.

Dealing with redirects using plugins might be somewhat different from what we went over above. You may need to read their paperwork to handle RegExp properly for the specific plugin.

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

Reroute Finest Practices

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

This case typically takes place 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 dealt with as 404s.

If you have too many pages like this, you need to think about creating beautiful 404 pages and engaging users to browse additional or find something other than what they were looking for by displaying a search alternative.

It is strongly recommended by Google that redirected page material need 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 different URLs for desktop and mobile sites (i.e., “example.com” for desktop and “m.example.com” for mobile), you ought to make sure to reroute users to the suitable page of the mobile variation.

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

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

If you have no mobile version for a page, you can prevent redirecting to the mobile version 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 place this tag in/ old-page/, it will redirect the user immediately to/ new-page/.

Google does not forbid this redirect, however it does not recommend using it.

According to John Mueller, online search engine may not have the ability to acknowledge that type of redirect effectively. The very same is also real about JavaScript redirects.

4. Prevent Redirect Chains

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

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

page 1 is rerouted and chosen to reroute page 2 to page 1 once again. As an outcome, 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 create an unlimited loop and produce the error revealed above. Conclusion Knowing what

redirects are and which circumstance requires a specific status code is basic to


websites properly. It’s a core part of understanding SEO. Numerous scenarios require accurate knowledge of redirects, such as moving a website to a new domain or developing a momentary holding page URL for a web page that will return under its normal URL. While a lot is possible with a plugin, plugins can be misused without properly understanding when and why to use a particular

type of redirect. More Resources: Featured Image: