URL Reroutes For SEO: A Technical Guide

Posted by

Reroutes for SEO needs to be utilized properly since they affect how sites are crawled and indexed by Google.

While many people consider redirects as an internet detour sign, much more is happening, and it’s remarkably satisfying to discover.

Keep checking out for an extensive summary of redirects and the appropriate application for technical SEO.

What Is A Redirect?

Website reroutes inform browsers and search engines details about a URL and where to find the webpage.

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

A redirect can be set as a:

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

When To Utilize Redirects

The main factors to utilize redirects are:

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

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

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

Redirects can be carried out on a group or domain-wide basis but frequently need to be set on a private basis to prevent problems.

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

Kinds of Redirects

There are three primary kinds of redirects:

  • Meta Refresh redirects are set at the page level however are usually not advised for SEO functions. There are 2 types of meta redirect: delayed which is viewed as a momentary redirect, and instant, which is seen as a permanent redirect.
  • Javascript redirects are likewise set on the customer side’s page and can trigger SEO concerns. Google has specified a preference for HTTP server-side reroutes.
  • HTTP redirects are set server-side and the best technique for SEO functions– we covered thorough below.

What Is A HTTP Response Status Code?

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

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

The action is called an HTTP response status code. It offers a status for the request for a URL.

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

For example, if the request for a URL achieves success, the server will provide a response code of 200, which means the request for a URL was successful.

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

HTTP Redirects

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

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

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

The entire 3xx series of response codes communicate much info that can additionally be acted on by the user agent.

An example of an action that the user agent can take is to save a cache of the new URL so that the next time the old URL is requested, it will request the new URL rather.

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

3XX Series Of Status Codes

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

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

These are the various sort of redirects offered for usage:

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

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

Since GoogleBot uses the most recent version of Chrome (called a headless web browser), it’s easy to examine if a status code works by checking if Chrome recognizes the status code with an internet browser compatibility list.

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

301: Moved Permanently

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

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

As discussed previously, there is more info too.

The 301 status code likewise recommends to the user agent:

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

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

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

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

Prior to making a modification, you must take care when utilizing a 301 redirect. The 301 redirects should just be used when the modification to a new URL is irreversible.

The 301 status code should not be used when the modification is short-term.

In addition, if you alter your mind later and go back to the old URL, the old URL might not rank anymore and may require time to gain back the rankings.

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

302: Found

The main thing to understand about the 302 status code is that it works for circumstances where a URL is briefly changed.

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

The 302 redirect status code likewise features a technical caveat associated to GET and Post:

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

The referral to “historical factors” might refer to old or buggy user representatives that might change the request approach.

307: Temporary Redirect

A 307 redirect suggests the requested URL is briefly moved, and the user representative should use the initial URL for future demands.

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

That suggests if the user representative demands the page with a GET request, then the user agent should use a GET request for the brand-new short-lived URL and can not use the POST request.

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

“The server sends this response to direct the client to get the asked for resource at another URI with same method that was utilized in the prior demand.

This has the same semantics as the 302 Found HTTP action code, with the exception that the user agent should not change the HTTP approach utilized: if a POST was used in the very first demand, a POST needs to be utilized in the 2nd demand.”

Besides the 307 status code needing subsequent demands to be of the exact same kind (POST or GET) which the 302 can go in any case, whatever else is the same between the 302 and the 307 status codes.

302 Vs. 307

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

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

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

(You can check out symlinks here.)

On Nginx servers, it will look like this:

reword ^/ oldfolder// newfolder/ irreversible;

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

For instance:

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

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

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

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

Options +FollowSymlinks RewriteEngine on

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

To comprehend the examples listed below, you may refer to the table below on RegExp essentials.

* zero or more times
+ Several times
. any single character
? Zero 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 Create Redirects

How To Produce A Redirect For A Single URL

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

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

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

We could also 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 redirected when we only 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 redirect in the list below kind:

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 because URLs are used to be shared over a social 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 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 other than” rule here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-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 4th line. We likewise have the “!-f” rule on the 2nd line, overlooking 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 cause an image break.

Directory site Modification

You can use the rule below if you did a category restructuring and wish to move everything from the old directory 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 must remember whatever 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 redirected to/ new-directory/subdirectory/.

I used 2 rules: one case with no routing slash at the end and the other one with a trailing slash.

I could integrate them into one guideline utilizing (/? |. *)$ RegExp at the end, but it would cause problems and add a “//” slash to the end of the URL when the asked for URL with no trailing slash has a query 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 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://% /$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://% /$1/$2 [NC, R=301, L] Set A Canonical URL

Having canonical URLs is the most fundamental part of SEO.

If missing, you may endanger your website with duplicate content concerns due to the fact that search engines deal with URLs with “www” and “non-www” versions as various pages with the same content.

Therefore, you should ensure you run the site just with one variation you choose.

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

RewriteCond % HTTP_HOST ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” version: RewriteCond % ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Tracking slash is also part of canonicalization since URLs with a slash at the end or without are also 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 pick to get rid of the slash rather of including then you will require the other rule listed below: RewriteCond % REQUEST_FILENAME!-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to motivate website owners to use SSL, migrating to HTTPS is one of the commonly utilized redirects that almost every site has.

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

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 combine a www or non-www version redirect into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise one of the most pre-owned redirects when you choose to rebrand and need to alter 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” because any page for historic factors may have inbound links to both versions.

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

Dealing with redirects using plugins may be a little various from what we discussed above. You may require to read their documents to manage RegExp correctly for the specific plugin.

From the existing ones, I would suggest a complimentary plugin called Redirection, which has many criteria to manage redirect rules and lots of beneficial docs.

Redirect Best Practices

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

This case often happens 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 producing gorgeous 404 pages and engaging users to search more or find something other than what they were looking for by displaying a search alternative.

It is highly advised by Google that redirected page content 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 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 need to ensure to reroute 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”

Also, you need to ensure 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 avoid 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 refresh tag like the example listed below:

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

Google does not forbid this redirect, however it doesn’t advise using it.

According to John Mueller, search engines may not be able to recognize that type of redirect correctly. The exact same is also real about JavaScript reroutes.

4. Prevent Redirect Chains

This message displays when you have an incorrect routine expression setup and ends up in an infinite loop.

Screenshot by author, December 2022 Typically, this takes place when you have a redirect chain. Let’s state you rerouted page 1 to page 2 a long period of time earlier. You might have forgotten that

page 1 is rerouted 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 mistake revealed above. Conclusion Understanding what

redirects are and which circumstance needs a specific status code is essential to

enhancing

webpages appropriately. It’s a core part of understanding SEO. Many situations require precise knowledge of redirects, such as moving a website to a new domain or creating a temporary holding page URL for a webpage that will return under its regular URL. While a lot 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: