URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO must be utilized correctly due to the fact that they affect how websites are crawled and indexed by Google.

While the majority of people consider redirects as an internet detour sign, a lot more is occurring, and it’s surprisingly pleasurable to find.

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

What Is A Redirect?

Site reroutes inform web browsers and search engines information about a URL and where to find 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 real URL that was input or clicked.

A redirect can be set as a:

  • Temporary redirect: 302, 303, 307, 308.
  • Permanent redirect: 301.

When To Use Redirects

The main factors to utilize redirects are:

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

For SEO functions, URL redirects are very important due to the fact that they:

  • Forward authority of any links indicating a page that has moved or been erased.
  • Prevent 404 page not found mistakes (although sometimes it is better to leave a 404).

Redirects can be carried out on a group or domain-wide basis however often need to be set on a specific basis to prevent issues.

When using RegEX for group reroutes, it can have unexpected outcomes if your logic isn’t perfect!

Types Of Redirects

There are three main kinds of redirects:

  • Meta Refresh redirects are set at the page level however are generally not advised for SEO purposes. There are 2 kinds of meta redirect: delayed which is seen as a short-lived redirect, and immediate, which is viewed as an irreversible redirect.
  • Javascript reroutes are also set on the customer side’s page and can trigger SEO concerns. Google has actually stated a preference for HTTP server-side redirects.
  • HTTP redirects are set server-side and the very best method for SEO functions– we covered thorough below.

What Is A HTTP Reaction Status Code?

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

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

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

In the circumstance where a user agent like GoogleBot requests a URL, the server provides an action.

For instance, if the request for a URL succeeds, the server will supply a reaction code of 200, which implies the ask for a URL succeeded.

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

HTTP Reroutes

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 agent that the URL request is being rerouted to a different URL.

The action code for a changed URL is usually in the form of a 301 or 302 reaction status code.

The whole 3xx series of response codes communicate much details that can additionally 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 ask for the brand-new URL rather.

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

3XX Series Of Status Codes

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

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

These are the different type of redirects offered for use:

  • 300 Numerous Options.
  • 301 Moved Permanently.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Temporary Redirect.
  • 308 Permanent 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 aside from 301 or 302, make sure that the designated user representative can analyze it.

Due to the fact that GoogleBot uses the current version of Chrome (called a headless browser), it’s easy to inspect if a status code works by checking if Chrome recognizes the status code with a web browser compatibility list.

For SEO, one need to stay with using the 301 and 302 action codes unless there is a particular reason to utilize among the other codes.

301: Moved Permanently

The 301 status code is regularly referenced as the 301 redirects. But the official name is 301 Moved Permanently.

The 301 redirect shows to a user agent that the URL (often referred to as a target resource or simply resource) was changed to another area and that it should utilize the brand-new URL for future demands.

As mentioned earlier, there is more details also.

The 301 status code likewise recommends to the user agent:

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

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

“Keep in mind: For historical reasons, a user representative MAY change the demand method from POST to GET for the subsequent demand. If this behavior is undesired, the 308 (Irreversible Redirect) status code can be used rather.”

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 beware when using a 301 redirect. The 301 redirects need to just be utilized when the modification to a brand-new URL is permanent.

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

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

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

302: Found

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

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

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

“Keep in mind: For historic reasons, a user representative MAY change the request approach from POST to GET for the subsequent demand. If this habits is unwanted, the 307 (Momentary Redirect) status code can be used instead.”

The referral to “historical factors” may describe old or buggy user agents that might change the demand approach.

307: Temporary Redirect

A 307 redirect implies the asked for URL is momentarily moved, and the user representative need to utilize the original URL for future requests.

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

That means if the user representative requests the page with a GET demand, then the user agent need to utilize a GET ask for the brand-new short-lived URL and can not utilize the POST request.

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

“The server sends this reaction to direct the client to get the asked for resource at another URI with exact same technique that was utilized in the previous demand.

This has the exact same semantics as the 302 Found HTTP response code, with the exception that the user agent need to not alter the HTTP technique utilized: if a POST was utilized in the first request, a POST must be utilized in the 2nd request.”

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

302 Vs. 307

You might 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 circumstances, they have the same syntax for composing redirect rules. They differ only with commands utilized in configuration files. For instance, a redirect on Apache will appear like this:

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

(You can check out symlinks here.)

On Nginx servers, it will appear like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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

For example:

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

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

On Apache, make sure that mod_rewrite and mod_alias modules (responsible for handling redirects) are allowed on your server.

Because the most extensively 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 guidelines and put the guidelines below them:

Alternatives +FollowSymlinks RewriteEngine on

Read the official documentation to get more information about the RewriteEngine.

To understand the examples below, you might refer to the table below on RegExp fundamentals.

* no 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 used when calling $1

How To Create Redirects

How To Develop A Redirect For A Single URL

The most typical and widely used type of redirect is when erasing pages or altering URLs.

For example, state 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 distinction between the 2 techniques is that the very first uses the Apache mod_rewrite module, and the 2nd uses mod_alias. It can be done utilizing both techniques.

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

We could likewise use (. *), i.e., ^/ old-page(. *), however the issue is, if you have another page with a comparable 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 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 reroute any variation of the page URL to a brand-new one. If we utilize reroute in the list below type:

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

Without routine expressions, all URLs with UTM query string, e.g.,/ old-page? utm_source=facebook.com (which prevails since URLs are used 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 state we have a bunch of URLs like/ category/old-subcategory -1/,/ category/old-subcategory -2/,/ category/final-subcategory/ and want to merge all subcategories into/ category/final-subcategory/. We require the “all other than” rule here.

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we want to reroute all under/ classification/ on the 3rd line except if it is/ category/final-subcategory/ on the fourth 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 properties like “/ category/image. jpg,” it will likewise be rerouted to “/ final-subcategory/” and trigger an image break.

Directory Modification

You can utilize the rule below if you did a category restructuring and want to move whatever 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 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 a result, it will be rerouted to/ new-directory/subdirectory/.

I used two guidelines: one case with no routing slash at the end and the other one with a tracking slash.

I could integrate them into one rule using (/? |. *)$ RegExp at the end, however it would trigger issues and add a “//” slash to the end of the URL when the asked for URL with no trailing slash has a question 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 remove 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 remains in the kind 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 may threaten your website with replicate content problems because online search engine treat URLs with “www” and “non-www” versions as different pages with the same material.

Therefore, you need to guarantee you run the site just with one version you choose.

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

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] Trailing slash is likewise part of canonicalization considering that URLs with a slash at the end or without are also dealt with differently. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is rerouted to/ example-page/. You may pick to eliminate the slash rather of adding then you will require the other guideline listed below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s initiative to encourage site owners to use SSL, moving to HTTPS is one of the commonly used redirects that practically every site has.

The reword guideline below can be utilized to force 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 integrate a www or non-www variation redirect into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise one of the most secondhand redirects when you decide to rebrand and need to alter your domain. The guideline listed 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 two cases: one with the “www” variation of URLs and another “non-www” due to the fact that any page for historical reasons may have incoming links to both versions.

A lot of site owners utilize WordPress and may not need a.htaccess declare redirects however use a plugin rather.

Managing redirects using plugins may be slightly different from what we discussed above. You may require to read their documentation to deal with RegExp correctly for the specific plugin.

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

Redirect Finest Practices

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

This case often takes place 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 a lot of pages like this, you ought to think about producing gorgeous 404 pages and engaging users to browse additional or discover something aside from what they were looking for by showing a search choice.

It is strongly suggested by Google that rerouted page content must be equivalent 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 websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you must ensure to redirect users to the proper page of the mobile version.

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

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

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

3. How To Utilize Meta Refresh

It is possible to do a redirect using a meta revitalize tag like the example below:

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

Google does not prohibit this redirect, however it does not suggest using it.

According to John Mueller, online search engine might not be able to recognize that type of redirect appropriately. The exact same is likewise real about JavaScript reroutes.

4. Prevent Redirect Chains

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

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

page 1 is rerouted and chosen to reroute page 2 to page 1 again. As an outcome, you will wind up with a guideline like this: RewriteRule ^ page1/ page2 [R

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

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


web pages properly. It’s a core part of comprehending SEO. Lots of scenarios require exact understanding of redirects, such as moving a site to a new domain or developing 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 properly understanding when and why to utilize a particular

sort of redirect. More Resources: Included Image: