URL Reroutes For SEO: A Technical Guide

Posted by

Redirects for SEO needs to be used correctly due to the fact that they impact how sites are crawled and indexed by Google.

While many people think about redirects as an internet detour indication, far more is happening, and it’s surprisingly enjoyable to discover.

Keep checking out for a detailed overview of redirects and the proper application for technical SEO.

What Is A Redirect?

Website reroutes inform internet browsers and online search engine details 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 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 Use Redirects

The primary factors to utilize redirects are:

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

For SEO purposes, URL redirects are important because 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 better to leave a 404).

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

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

Kinds of Redirects

There are three primary types of redirects:

  • Meta Refresh redirects are set at the page level but are usually not suggested for SEO functions. There are 2 kinds of meta redirect: delayed which is seen as a momentary redirect, and instant, which is seen as an irreversible redirect.
  • Javascript redirects are also set on the customer side’s page and can cause SEO issues. Google has actually mentioned a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best technique for SEO purposes– we covered thorough listed below.

What Is A HTTP Action Status Code?

Internet browsers and online search engine crawlers like GoogleBot are called user agents.

When a user representative attempts to access a web page, what occurs is that the user representative makes a request, and the website server concerns a response.

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

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

For instance, if the ask for a URL achieves success, the server will supply a response code of 200, which indicates the request for a URL succeeded.

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

HTTP Redirects

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

If the URL exists at a various 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 normally in the kind of a 301 or 302 response status code.

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

An example of an action that the user agent 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 for the brand-new URL instead.

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

3XX Series Of Status Codes

Redirects are more than simply the 2 status codes everyone recognizes 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 Multiple Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Customized.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Momentary Redirect.
  • 308 Irreversible Redirect.

Some of the above status codes have actually not been around as long and might not be used. So, prior to utilizing any redirect code besides 301 or 302, make sure that the intended user representative can translate it.

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

For SEO, one need to adhere to utilizing the 301 and 302 reaction codes unless there is a particular reason to use one of the other codes.

301: Moved Permanently

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

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

As mentioned earlier, there is more information also.

The 301 status code likewise recommends to the user representative:

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

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

“Keep in mind: For historic factors, a user representative MAY alter the request technique from POST to GET for the subsequent request. If this habits is undesirable, the 308 (Permanent Redirect) status code can be utilized 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 need to beware when using a 301 redirect. The 301 redirects must only be used when the modification to a new URL is long-term.

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

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

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

302: Found

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

The meaning of this response code is that the URL is temporarily at a different URL, and it is suggested to utilize the old URL for future requests.

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

“Note: For historic reasons, a user representative MAY alter the request technique from POST to GET for the subsequent request. If this behavior is undesirable, the 307 (Short-lived Redirect) status code can be utilized rather.”

The reference to “historic reasons” may refer to old or buggy user representatives that might alter the request approach.

307: Temporary Redirect

A 307 redirect means the requested URL is briefly moved, and the user agent must use the original 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 brand-new URL with the exact same HTTP demand utilized to request the original URL.

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

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

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

This has the very same semantics as the 302 Found HTTP response code, with the exception that the user representative need to not change the HTTP technique utilized: if a POST was used in the first request, a POST must be used in the 2nd 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 any case, everything else is the exact same in between the 302 and the 307 status codes.

302 Vs. 307

You might manage a redirect through 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 very same syntax for composing redirect rules. They differ only with commands used in configuration files. For example, 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 look like this:

rewrite ^/ oldfolder// newfolder/ irreversible;

The commands utilized to inform 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.”

But 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 allowed on your server.

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

Make sure that the.htaccess file has these two lines above the redirect rules and put the rules below them:

Choices +FollowSymlinks RewriteEngine on

Read the official paperwork for more information about the RewriteEngine.

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

* zero or more times
+ One or more times
. any single character
? Zero or one time
^ Start of the string
$ End of the string
| b OR operadn” |” a or b
(z) remembers the match to be utilized when calling $1

How To Develop Redirects

How To Develop A Redirect For A Single URL

The most typical and extensively utilized kind of redirect is when deleting 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 difference in between the two techniques is that the very first uses the Apache mod_rewrite module, and the 2nd usages mod_alias. It can be done utilizing both methods.

The regular 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 must be rerouted to/ new-page/.

We might also use (. *), i.e., ^/ old-page(. *), however the issue is, if you have another page with a similar URL like/ old-page-other/, it will also be rerouted 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 form:

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

Without regular expressions, all URLs with UTM inquiry string, e.g.,/ old-page? utm_source=facebook.com (which prevails given that URLs are used to be shared over a social media), would end up as 404s.

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

Redirect All Other than

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

RewriteCond % REQUEST_URI!/ category/final-subcategory/ RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(category/)./ category/final-subcategory/ [R=301, L] Here, we wish to redirect all under/ category/ on the 3rd line except if it is/ category/final-subcategory/ on the fourth line. We also 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 likewise be redirected to “/ final-subcategory/” and cause an image break.

Directory site Change

You can use the guideline listed 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 used $1 in the target to tell the server that it need to keep in mind whatever 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 redirected to/ new-directory/subdirectory/.

I utilized 2 guidelines: one case with no trailing slash at the end and the other one with a tracking slash.

I could integrate them into one rule utilizing (/? |. *)$ RegExp at the end, but it would cause problems and include a “//” slash to the end of the URL when the asked for URL without any trailing slash has a query string (i.e., “/ old-directory? utm_source=facebook” would be rerouted to “/ new-directory//? utm_source=facebook”).

Eliminate A Word From URL

Let’s state you have 100 URLs on your site with the city name “Chicago” and want to eliminate 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 remains in the form 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 out on, you may endanger your website with replicate content problems because online search engine treat URLs with “www” and “non-www” variations as different pages with the very same material.

For that reason, you must guarantee you run the site only with one version you pick.

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

RewriteCond % ^ yourwebsite.com [NC] RewriteRule ^(. *)$ http://www.yourwebsite.com/$1 [L, R=301] For a “non-www” version: RewriteCond % HTTP_HOST ^ www.yourwebsite.com [NC] RewriteRule ^(. *)$ http://yourwebsite.com/$1 [L, R=301] Trailing slash is also part of canonicalization given that URLs with a slash at the end or without are also treated differently. RewriteCond % !-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will make sure the/ example-page is rerouted to/ example-page/. You might choose to eliminate the slash instead of including then you will require the other guideline listed below: RewriteCond % !-d RewriteRule ^(. *)/$/$1 [L, R=301]HTTP To HTTPS Redirect

After Google’s effort to encourage website owners to use SSL, moving to HTTPS is one of the commonly used redirects that almost every website has.

The reword 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] Utilizing this, you can integrate a www or non-www variation reroute into one HTTPS redirect rule.

Redirect From Old Domain To New

This is likewise one of the most used 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 % ^ 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” due to the fact that any page for historic reasons may have inbound links to both versions.

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

Dealing with redirects using plugins might be slightly various from what we talked about above. You might require to read their documents to deal with RegExp properly for the particular plugin.

From the existing ones, I would advise a free plugin called Redirection, which has numerous parameters to control redirect guidelines and lots of helpful docs.

Reroute Finest Practices

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

This case typically happens when you are too lazy to examine your 404 URLs and map them to the appropriate landing page.

According to Google, they are still all dealt with as 404s.

If you have a lot of pages like this, you should think about creating stunning 404 pages and engaging users to search further or find something other than what they were searching for by displaying a search alternative.

It is highly recommended by Google that rerouted page content need to be equivalent 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 websites (i.e., “example.com” for desktop and “m.example.com” for mobile), you must make sure 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”

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

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

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

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

According to John Mueller, online search engine might not be able to acknowledge that type of redirect correctly. The exact same is also true about JavaScript reroutes.

4. Avoid Redirect Chains

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

Screenshot by author, December 2022 Normally, this takes place when you have a redirect chain. Let’s state you rerouted page 1 to page 2 a very long time earlier. You may 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 develop an unlimited loop and produce the error revealed above. Conclusion Knowing what

redirects are and which scenario needs a particular status code is fundamental to


webpages properly. It’s a core part of comprehending SEO. Numerous circumstances need accurate understanding of redirects, such as migrating a site to a brand-new domain or developing a momentary 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 understanding when and why to use a specific

sort of redirect. More Resources: Featured Image: