URL Reroutes For SEO: A Technical Guide

Posted by

Redirects for SEO should be used properly due to the fact that they affect how websites are crawled and indexed by Google.

While most people think of redirects as an internet detour indication, a lot more is occurring, and it’s surprisingly enjoyable to discover.

Keep reading for an extensive introduction of redirects and the correct application for technical SEO.

What Is A Redirect?

Site reroutes tell internet browsers and online search engine info about a URL and where to discover the web page.

A URL redirect includes code carried out to a specific URL, or a group of URLs so that the user (or search engine) is sent out to a various page to the real 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 Use Redirects

The main reasons to use redirects are:

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

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

  • Forward authority of any links pointing to a page that has moved or been deleted.
  • Prevent 404 page not discovered errors (although often it is better to leave a 404).

Redirects can be carried out on a group or domain-wide basis but often need to be set on a private basis to avoid issues.

When using RegEX for group redirects, it can have unanticipated 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 normally not suggested for SEO functions. There are 2 kinds of meta redirect: postponed which is seen as a short-lived redirect, and instant, which is viewed as an irreversible redirect.
  • Javascript reroutes are likewise set on the client side’s page and can cause SEO issues. Google has specified a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the best approach for SEO purposes– we covered thorough listed below.

What Is A HTTP Response Status Code?

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

When a user agent attempts to access a website, what takes place is that the user agent makes a demand, and the website server concerns a reaction.

The response is called an HTTP reaction status code. It provides a status for the ask for a URL.

In the situation where a user agent like GoogleBot demands a URL, the server gives an action.

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

So, when you consider a GoogleBot reaching a website and trying to crawl it, what’s happening is a series of demands and responses.

HTTP Redirects

An HTTP redirect is a server response to ask for a URL.

If the URL exists at a different URL (due to the fact that it was moved), the server tells the user agent that the URL request is being redirected to a various URL.

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

The whole 3xx series of reaction codes interact much info 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 brand-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 road indication that states, “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 response codes.

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

These are the different sort of redirects readily available for usage:

  • 300 Multiple Options.
  • 301 Moved Completely.
  • 302 Found.
  • 303 See Other.
  • 304 Not Modified.
  • 305 Usage Proxy.
  • 306 (Unused).
  • 307 Short-lived Redirect.
  • 308 Long-term Redirect.

A few of the above status codes have not been around as long and may not be utilized. So, before using any redirect code besides 301 or 302, be sure that the designated user agent can analyze it.

Since GoogleBot utilizes the latest version of Chrome (called a headless 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 ought to adhere to utilizing the 301 and 302 action codes unless there is a particular reason to utilize one of the other codes.

301: Moved Completely

The 301 status code is routinely referenced as the 301 redirects. But the main name is 301 Moved Permanently.

The 301 redirect shows to a user representative that the URL (often described as a target resource or simply resource) was changed to another area and that it ought to use the new URL for future requests.

As pointed out earlier, there is more information also.

The 301 status code also suggests to the user representative:

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

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

“Note: For historic factors, a user representative MAY change the request approach from POST to GET for the subsequent request. If this behavior is undesired, the 308 (Permanent Redirect) status code can be utilized rather.”

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

Before making a change, you must beware when utilizing a 301 redirect. The 301 redirects must only be utilized when the change to a new URL is long-term.

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

Furthermore, if you change your mind later and go back to the old URL, the old URL may not rank any longer and may take time to regain the rankings.

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

302: Found

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

The significance of this response code is that the URL is briefly at a various URL, and it is suggested to use the old URL for future demands.

The 302 redirect status code also includes a technical caution associated to GET and Post:

“Note: For historical factors, a user agent MAY alter the demand approach from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used rather.”

The recommendation to “historical factors” may refer to old or buggy user agents that might change the request approach.

307: Temporary Redirect

A 307 redirect indicates the requested URL is temporarily moved, and the user representative need to utilize 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 exact same HTTP demand used to request the original URL.

That suggests if the user representative requests the page with a GET demand, then the user agent should 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 clearly than the official documents.

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

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

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

302 Vs. 307

You might deal with 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 circumstances, they have the same syntax for composing redirect rules. They vary only with commands utilized 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 look like this:

rewrite ^/ oldfolder// newfolder/ permanent;

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

For instance:

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

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

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

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

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

Options +FollowSymlinks RewriteEngine on

Read the official documentation for more information about the RewriteEngine.

To comprehend the examples below, you might describe the table below on RegExp fundamentals.

* zero 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) remembers the match to be used when calling $1

How To Develop Redirects

How To Develop A Redirect For A Single URL

The most typical and extensively 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 guideline would be:

RewriteRule ^ old-page(/? |/. *)$/ new-page/ [R=301, L] Or RedirectMatch 301 ^/ old-page(/? |/. *)$/ new-page/

The only distinction in between the 2 techniques is that the first utilizes the Apache mod_rewrite module, and the 2nd usages mod_alias. It can be done utilizing both techniques.

The routine expression “^” suggests the URL must start with “/ old-page” while (/? |/. *)$ shows that anything that follows “/ old-page/” with a slash “/” or without a precise match should be redirected 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 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 reroute any variation of the page URL to a new one. If we utilize redirect 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 prevails since URLs are utilized to be shared over a social media), would end up as 404s.

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

Redirect All Other than

Let’s say 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 except” rule here.

RewriteCond % !/ category/final-subcategory/ RewriteCond % !-f RewriteRule ^(classification/)./ category/final-subcategory/ [R=301, L] Here, we wish to reroute all under/ classification/ on the 3rd line except if it is/ category/final-subcategory/ on the fourth line. We also have the “!-f” rule on the second line, overlooking 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 site Change

You can use the rule below if you did a category restructuring and want 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 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 redirected to/ new-directory/subdirectory/.

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

I could integrate them into one guideline utilizing (/? |. *)$ RegExp at the end, but it would trigger issues and include a “//” slash to the end of the URL when the asked for URL without any trailing 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 say you have 100 URLs on your site with the city name “Chicago” and wish 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 type 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 important part of SEO.

If missing out on, you may threaten your site with duplicate content issues since search engines deal with URLs with “www” and “non-www” variations as different pages with the very same content.

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

If you want to run your website with the “www” variation, 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 likewise part of canonicalization because URLs with a slash at the end or without are likewise dealt with in a different way. RewriteCond % REQUEST_FILENAME!-f RewriteRule ^(. * [^/]$/$1/ [L, R=301] This will ensure the/ example-page is redirected to/ example-page/. You may choose to get rid of the slash instead of including 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 effort to motivate website owners to utilize SSL, moving to HTTPS is one of the frequently utilized redirects that almost every site has.

The reword rule listed below can be used to require 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 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 decide to rebrand and need to change your domain. The rule listed below redirects old-domain. com to new-domain. com.

RewriteCond % HTTP_HOST ^ 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” version of URLs and another “non-www” since any page for historic reasons may have inbound links to both versions.

The majority of website owners utilize WordPress and might not need a.htaccess apply for redirects but use a plugin rather.

Dealing with redirects utilizing plugins may be slightly various from what we discussed above. You might need to read their documents to handle RegExp correctly for the particular plugin.

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

Redirect Finest Practices

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

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

If you have a lot of pages like this, you should think about producing lovely 404 pages and engaging users to search additional or discover something other than what they were trying to find by showing a search alternative.

It is highly advised by Google that rerouted page content must be comparable to the old page. Otherwise, such a redirect might be considered 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 ensure to redirect users to the suitable page of the mobile version.

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

Also, you need to make sure that if one page is 404 on the desktop, it should likewise be 404 on mobile.

If you have no mobile variation for a page, you can prevent redirecting to the mobile version 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, but it does not suggest using it.

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

4. Prevent Redirect Chains

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

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

page 1 is rerouted and decided to reroute page 2 to page 1 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 infinite loop and produce the error revealed above. Conclusion Knowing what

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


websites appropriately. It’s a core part of comprehending SEO. Lots of scenarios need precise knowledge of redirects, such as migrating a website to a new domain or creating a short-lived holding page URL for a webpage that will return under its normal URL. While a lot is possible with a plugin, plugins can be misused without correctly comprehending when and why to utilize a particular

type of redirect. More Resources: Included Image: