URL Redirects For search engine marketing: A Technical Information

Redirects for search engine marketing ought to be used accurately as a result of they impression how web sites are crawled and listed by Google.

Whereas most individuals consider redirects as an web detour signal, way more is occurring, and it’s surprisingly gratifying to find.

Preserve studying for a complete overview of redirects and the correct software for technical search engine marketing.

What Is A Redirect?

Web site redirects inform browsers and search engines like google and yahoo details about a URL and the place to search out the webpage.

A URL redirect includes code carried out to a particular URL, or a bunch of URLs in order that the person (or search engine) is shipped to a unique web page to the precise URL that was enter or clicked.

A redirect could be set as a:

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

When To Use Redirects

The primary causes to make use of redirects are:

  • A person web page or total area has been moved (URL modified).
  • To permit using URL shorteners or ‘fairly URLs.’
  • Web site migration (e.g., HTTP to HTTPS).

For search engine marketing functions, URL redirects are essential as a result of they:

  • Ahead authority of any hyperlinks pointing to a web page that has moved or been deleted.
  • Keep away from 404 web page not discovered errors (though generally it’s higher to depart a 404).

Redirects could be carried out on a bunch or domain-wide foundation however usually have to be set on a person foundation to keep away from points.

When utilizing RegEX for group redirects, it may have sudden outcomes in case your logic isn’t flawless!

Sorts Of Redirects

There are three foremost kinds of redirects:

  • Meta Refresh redirects are set on the web page degree however are typically not really helpful for search engine marketing functions. There are two kinds of meta redirect: delayed which is seen as a brief redirect, and on the spot, which is seen as a everlasting redirect.
  • Javascript redirects are additionally set on the consumer aspect’s web page and may trigger search engine marketing points. Google has said a choice for HTTP server-side redirects.
  • HTTP redirects are set server-side and the perfect strategy for search engine marketing functions – we coated in-depth under.

What Is A HTTP Response Standing Code?

Browsers and search engine crawlers like GoogleBot are referred to as person brokers.

When a person agent tries to entry a webpage, what occurs is that the person agent makes a request, and the web site server points a response.

The response is known as an HTTP response standing code. It supplies a standing for the request for a URL.

Within the scenario the place a person agent like GoogleBot requests a URL, the server provides a response.

For instance, if the request for a URL is profitable, the server will present a response code of 200, which suggests the request for a URL was profitable.

So, while you consider a GoogleBot reaching a web site and attempting to crawl it, what’s taking place is a sequence of requests and responses.

HTTP Redirects

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

If the URL exists at a unique URL (as a result of it was moved), the server tells the person agent that the URL request is being redirected to a unique URL.

The response code for a modified URL is normally within the type of a 301 or 302 response standing code.

All the 3xx sequence of response codes talk a lot data that may optionally be acted upon by the person agent.

An instance of an motion that the person agent can take is to save lots of a cache of the brand new URL in order that the following time the previous URL is requested, it’ll ask for the brand new URL as a substitute.

So, a 301 and a 302 redirect is greater than an web highway signal that claims, “Go right here, not there.”

3XX Collection Of Standing Codes

Redirects are extra than simply the 2 standing codes everyone seems to be accustomed to, the 301 and 302 response codes.

There are a complete of seven official 3xx response standing codes.

These are the totally different sorts of redirects obtainable to be used:

  • 300 A number of Selections.
  • 301 Moved Completely.
  • 302 Discovered.
  • 303 See Different.
  • 304 Not Modified.
  • 305 Use Proxy.
  • 306 (Unused).
  • 307 Short-term Redirect.
  • 308 Everlasting Redirect.

A few of the above standing codes haven’t been round as lengthy and may not be used. So, earlier than utilizing any redirect code aside from 301 or 302, make sure that the supposed person agent can interpret it.

As a result of GoogleBot makes use of the most recent model of Chrome (referred to as a headless browser), it’s simple to examine if a standing code is appropriate by checking if Chrome acknowledges the standing code with a browser compatibility record.

For search engine marketing, one ought to stick with utilizing the 301 and 302 response codes until there’s a particular purpose to make use of one of many different codes.

301: Moved Completely

The 301 standing code is routinely referenced because the 301 redirects. However the official identify is 301 Moved Completely.

The 301 redirect signifies to a person agent that the URL (generally known as a goal useful resource or just useful resource) was modified to a different location and that it ought to use the brand new URL for future requests.

As talked about earlier, there may be extra data as effectively.

The 301 standing code additionally suggests to the person agent:

  • Future requests for the URL ought to be made with the brand new URL.
  • Whoever is making the request ought to replace their hyperlinks to the brand new URL.
  • Subsequent requests could be modified from GET to POST.

That final level is a technical problem. In keeping with the official requirements for the 301 standing code:

“Word: For historic causes, a person agent MAY change the request methodology from POST to GET for the next request. If this conduct is undesired, the 308 (Everlasting Redirect) standing code can be utilized as a substitute.”

For search engine marketing, when search engines like google and yahoo see a 301 redirect, they cross the previous web page’s rating to the brand new one.

Earlier than making a change, you should be cautious when utilizing a 301 redirect. The 301 redirects should solely be used when the change to a brand new URL is everlasting.

The 301 standing code should not be used when the change is non permanent.

Moreover, when you change your thoughts later and return to the previous URL, the previous URL could not rank anymore and should take time to regain the rankings.

So, the primary factor to recollect is {that a} 301 standing code will likely be used when the change is everlasting.

302: Discovered

The primary factor to grasp concerning the 302 standing code is that it’s helpful for conditions the place a URL is briefly modified.

The which means of this response code is that the URL is briefly at a unique URL, and it’s recommended to make use of the previous URL for future requests.

The 302 redirect standing code additionally comes with a technical caveat associated to GET and Submit:

“Word: For historic causes, a person agent MAY change the request methodology from POST to GET for the next request. If this conduct is undesired, the 307 (Short-term Redirect) standing code can be utilized as a substitute.”

The reference to “historic causes” could consult with previous or buggy person brokers that will change the request methodology.

307: Short-term Redirect

A 307 redirect means the requested URL is briefly moved, and the person agent ought to use the unique URL for future requests.

The one distinction between a 302 and a 307 standing code is {that a} person agent should request the brand new URL with the identical HTTP request used to request the unique URL.

Meaning if the person agent requests the web page with a GET request, then the person agent should use a GET request for the brand new non permanent URL and can’t use the POST request.

The Mozilla documentation of the 307 standing code explains it extra clearly than the official documentation.

“The server sends this response to direct the consumer to get the requested useful resource at one other URI with identical methodology that was used within the prior request.

This has the identical semantics because the 302 Discovered HTTP response code, with the exception that the person agent should not change the HTTP methodology used: if a POST was used within the first request, a POST should be used within the second request.”

Aside from the 307 standing code requiring subsequent requests to be of the identical sort (POST or GET) and that the 302 can go both means, all the things else is identical between the 302 and the 307 standing codes.

302 Vs. 307

You could deal with a redirect by way of server config information .htaccess on Apache, instance.conf file on Nginx or by way of plugins in case you are utilizing WordPress.

In all situations, they’ve the identical syntax for writing redirect guidelines. They differ solely with instructions utilized in configuration information. For instance, a redirect on Apache will appear to be this:

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

(You may examine symlinks right here.)

On Nginx servers, it’ll appear to be this:

rewrite ^/oldfolder/ /newfolder/ everlasting;

The instructions used to inform the server’s standing code of redirect and the motion command differ.

As an example:

  • Servers standing code of redirect: “301″ vs. “everlasting.”
  • Motion command: “RedirectMatch” vs. “rewrite.”

However the redirect syntax ( ^/oldfolder/ /newfolder/ ) is identical for each.

On Apache, be sure that mod_rewrite and mod_alias modules (answerable for dealing with redirects) are enabled in your server.

Because the most generally unfold server kind is Apache, listed here are examples for .htaccess apache information.

Guarantee that the .htaccess file has these two strains above the redirect guidelines and put the principles under them:

Choices +FollowSymlinks
RewriteEngine on

Learn the official documentation to be taught extra concerning the RewriteEngine.

To know the examples under, you could consult with the desk under on RegExp fundamentals.

* zero or extra instances
+ A number of instances
. any single character
? Zero or one time
^ Begin of the string
$ Finish of the string
a|b OR operadn “|” a or b
(z) remembers the match for use when calling $1

How To Create Redirects

How To Create A Redirect For A Single URL

The most typical and broadly used kind of redirect is when deleting pages or altering URLs.

As an example, say you modified the URL from /old-page/ to /new-page/. The redirect rule could be:

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


RedirectMatch 301 ^/old-page(/?|/.*)$ /new-page/

The one distinction between the 2 strategies is that the primary makes use of the Apache mod_rewrite module, and the second makes use of mod_alias. It may be performed utilizing each strategies.

The common expression “^” means the URL should begin with “/old-page” whereas (/?|/.*)$ signifies that something that follows “/old-page/” with a slash “/” or with out a precise match should be redirected to /new-page/.

We might additionally use (.*), i.e., ^/old-page(.*), however the issue is, in case you have one other web page with the same URL like /old-page-other/, it’ll even be redirected once we solely wish to redirect /old-page/.

The next URLs will match and be directed to a brand new web page:

/old-page/ /new-page/
/old-page /new-page/
/old-page/? /new-page/?
/old-page/child-page/ /new-page/

It’ll redirect any variation of the web page URL to a brand new one. If we use redirect within the following kind:

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

With out common expressions, all URLs with UTM question string, e.g., /old-page? (which is widespread since URLs are was once shared over a social community), would find yourself as 404s.

Even /old-page with no trailing slash “/” would find yourself as a 404.

Redirect All Besides

Let’s say we’ve a bunch of URLs like /class/old-subcategory-1/, /class/old-subcategory-2/, /class/final-subcategory/ and wish to merge all subcategories into /class/final-subcategory/. We’d like the “all besides” rule right here.

RewriteCond %{REQUEST_URI} !/class/final-subcategory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(class/). /class/final-subcategory/ [R=301,L]

Right here, we wish to redirect all beneath /class/ on the third line besides whether it is /class/final-subcategory/ on the fourth line. We even have the “!-f” rule on the second line, ignoring any file like pictures, CSS, or JavaScript information.

In any other case, if we’ve some property like “/class/picture.jpg,” it’ll even be redirected to “/final-subcategory/” and trigger a picture break.

Listing Change

You should utilize the rule under when you did a class restructuring and wish to transfer all the things from the previous listing 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 within the goal to inform the server that it ought to keep in mind all the things within the URL that follows /old-directory/ (i.e., /old-directory/subdirectory/) and cross it (i.e., “/subdirectory/”) onto the vacation spot. Consequently, it is going to be redirected to /new-directory/subdirectory/.

I used two guidelines: one case with no trailing slash on the finish and the opposite one with a trailing slash.

I might mix them into one rule utilizing (/?|.*)$ RegExp on the finish, however it will trigger issues and add a “//” slash to the tip of the URL when the requested URL with no trailing slash has a question string (i.e., “/old-directory?utm_source=fb” could be redirected to “/new-directory//?utm_source=fb”).

Take away A Phrase From URL

Let’s say you’ve gotten 100 URLs in your web site with the town identify “Chicago” and wish to take away them.

For the URL, the redirect rule could be:

RewriteRule ^(.*)-chicago-(.*) http://%{SERVER_NAME}/$1-$2 [NC,R=301,L]

If the instance URL is within the kind, then the redirect could be:

RewriteRule ^(.*)/chicago/(.*) http://%{SERVER_NAME}/$1/$2 [NC,R=301,L]

Set A Canonical URL

Having canonical URLs is crucial a part of search engine marketing.

If lacking, you would possibly endanger your web site with duplicate content material points as a result of search engines like google and yahoo deal with URLs with “www” and “non-www” variations as totally different pages with the identical content material.

Subsequently, you need to make sure you run the web site solely with one model you select.

If you wish to run your web site with the “www” model, use this rule:

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

For a “non-www” model:

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

Trailing slash can be a part of canonicalization since URLs with a slash on the finish or with out are additionally handled otherwise.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

It will be certain that the /example-page is redirected to /example-page/. You could select to take away the slash as a substitute of including then you will have the opposite rule under:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

HTTP To HTTPS Redirect

After Google’s initiative to encourage web site house owners to make use of SSL, migrating to HTTPS is without doubt one of the generally used redirects that nearly each web site has.

The rewrite rule under can be utilized to drive HTTPS on each web site.

RewriteCond %{HTTP_HOST} ^ [NC,OR]
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301,NC]

Utilizing this, you’ll be able to mix a www or non-www model redirect into one HTTPS redirect rule.

Redirect From Previous Area To New

That is additionally probably the most used redirects while you determine to rebrand and want to vary your area. The rule under redirects to

RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule (.*)$$1 [R=301,L]

It makes use of two instances: one with the “www” model of URLs and one other “non-www” as a result of any web page for historic causes could have incoming hyperlinks to each variations.

Most website house owners use WordPress and should not want a .htaccess file for redirects however use a plugin as a substitute.

Dealing with redirects utilizing plugins could also be barely totally different from what we mentioned above. You could have to learn their documentation to deal with RegExp accurately for the precise plugin.

From the present ones, I might advocate a free plugin referred to as Redirection, which has many parameters to manage redirect guidelines and plenty of helpful docs.

Redirect Greatest Practices

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

This case usually occurs if you find yourself too lazy to research your 404 URLs and map them to the suitable touchdown web page.

In keeping with Google, they’re nonetheless all handled as 404s.

When you have too many pages like this, it is best to take into account creating lovely 404 pages and fascinating customers to browse additional or discover one thing aside from what they have been in search of by displaying a search possibility.

It’s strongly really helpful by Google that redirected web page content material ought to be equal to the previous web page. In any other case, such a redirect could also be thought of a gentle 404, and you’ll lose the rank of that web page.

2. Get Cell Web page-Particular Redirects Proper

When you have totally different URLs for desktop and cellular web sites (i.e., “” for desktop and “” for cellular), it is best to be certain that to redirect customers to the suitable web page of the cellular model.

Appropriate: “” to “”
Mistaken: “” to “”

Additionally, you must be sure that if one web page is 404 on the desktop, it must also be 404 on cellular.

When you have no cellular model for a web page, you’ll be able to keep away from redirecting to the cellular model and hold them on the desktop web page.

3. How To Use Meta Refresh

It’s potential to do a redirect utilizing a meta refresh tag like the instance under:

<meta http-equiv=”refresh” content material=”0;url=” />

For those who insert this tag in /old-page/, it’ll redirect the person instantly to /new-page/.

Google doesn’t prohibit this redirect, but it surely doesn’t advocate utilizing it.

In keeping with John Mueller, search engines like google and yahoo could not have the ability to acknowledge that kind of redirect correctly. The identical can be true about JavaScript redirects.

4. Keep away from Redirect Chains

This message shows when you’ve gotten a mistaken common expression setup and results in an infinite loop.

Screenshot by writer, December 2022

Often, this occurs when you’ve gotten a redirect chain.

Let’s say you redirected web page 1 to web page 2 a very long time in the past. You might need forgotten that web page 1 is redirected and determined to redirect web page 2 to web page 1 once more.

Consequently, you’ll find yourself with a rule like this:

RewriteRule ^page1 /page2 [R=301,NC,L]
RewriteRule ^page2 /page1 [R=301,NC,L]

It will create an infinite loop and produce the error proven above.


Realizing what redirects are and which scenario requires a particular standing code is key to optimizing webpages correctly. It’s a core a part of understanding search engine marketing.

Many conditions require exact data of redirects, comparable to migrating a web site to a brand new area or creating a brief holding web page URL for a webpage that may return beneath its regular URL.

Whereas a lot is feasible with a plugin, plugins could be misused with out correctly understanding when and why to make use of a specific type of redirect.

Extra Assets:

Featured Picture: 

Leave a Reply

Your email address will not be published. Required fields are marked *

Schedule Call

👋🏻 Hi friend, how are you today?

Need help? contact us here... 👇