HOW TO DO A 301 REDIRECT

How to implement the right type of redirection
Do you know how to do a 301 redirect for your site? Or do you just want to know more about it?

You have come to the right place: on this page, we will understand what it means to make a redirect or redirection, how to choose the right type of redirect, and how to actually implement redirection for your site, page, or domain.

how to do a 301 redirect example

Redirect: what it is and why it is important

What is a redirect? When we talk about how to do a redirect or redirection, we are talking about a feature that allows us to switch from one domain name to another without the user noticing. While the reasons for doing a redirect are many and vary depending on the type, the importance of correctly implementing the redirect is unequivocal.

This practice is very important not only to ensure better site usability for the user but also to protect the strength gained by one’s domain. In fact, from an SEO point of view, it is important to maintain the position that one’s domain has attained, making a redirect allows one (in 90% of cases) to maintain one’s ranking firmly (read also Checking site positioning on search engines).

Why it is important :

  • Allows you to protect your brand identity on the net: it allows you to purchase all available extensions for your domain name and have them converge to the main
  • Minimise resources to develop your website: you need a single hosting service on which to develop your site, to which domains with different extensions will be attached
  • Allows you to maintain your SEO ranking: while the site is under maintenance you can do a redirect in order to avoid the 404 error (page not found).
  • Allows you to improve your SEO ranking: having multiple domain extensions pointing to one site makes your web presence stronger
  • It allows the user experience to be strengthened: think of the case when a product of e-commerce has gone out of production, to avoid the user ending up on a “page not found” page, a redirect is made. The user will thus obtain maximum usability from his site and contribute to its loyalty.
  • It is the only way to:E’ l’unico modo per:
    • redirect an entire domain to another domain: e.g. one can redirect “www.ilmiosito.com” to “www.ilmiosito.it”.
    • redirect a web page to another web page: e.g. “www.ilmiosito.it/about” can be redirected to “www.ilmiosito.it/home”.
    • carry out a change of protocol: i.e. from “http://…” to “https://…”.

Technically speaking, to understand how to do a redirect, we have to understand in the IT world what a redirect is: a redirect is an HTTP response code.

HTTP response codes have assigned numbers that tell the server how to respond to a request from the URL. These numeric codes inform the browser, as well as the crawlers, how to handle the request.

The code that can be called “the most famous” is the error code 404, i.e. “page not found”. In the field of SEO (Search Engine Optimization), the codes referred to are 301 and 302, i.e. redirect codes; it is important to know when to use one and when to use the other because when the code changes, there can be significant changes for your site/page in terms of effectiveness, ranking and SEO efforts.

The person who handles redirects is the SEO Specialist, a figure in great demand by companies. Find out with a test if this role is right for you!

seo specialist test

Redirect 301 vs Redirect 302

If it is difficult for a user to understand how 301 and 302 redirects work, many webmasters would also like to know in more detail how to make a redirect and choose the most effective one for their case. Search engines act and handle different types of redirects in different worlds.

Let us start with the main difference:

  • REDIRECT 301: making a 301 redirect means that the page has moved to a new one permanently
  • REDIRECT 302: making a 302 redirect means that the page has moved to another one temporarily

Search engines must decide, based on the code that is typed in, whether to keep the old page or replace it with the one in the new position. You understand that swapping one redirect for the other can cause confusion in the machine; if this happens, the search engine will act in such a way as to bring less traffic to your site.

Understanding how to redirect is crucial, especially in certain situations.

For instance, when you want to move your website or just a page to a new location, you want your visitors to be able to find you on the new domain. The redirection allows the user to be directed at the new URL, without having to go through an old, restructured, or non-existent page. It would all be very simple if there were not also the issues of “Google aging delays” involved because while moving a site, these issues can be triggered and the site can fall out of the ranking for months or even years.

When is it good to use a 302 redirect? How to make a 302 redirect and in what situations does it apply?

Not many to tell the truth, you are much more likely to need to move a page permanently than for a short period. Unfortunately, however, it is easier to do a 302 redirect than a 301. For a 302, in fact, just use:

  • Javascript
  • Using the meta tag

If you do not want to resort to the WordPress plug-in, doing a 301 redirect requires somewhat more advanced skills:

  • if you use an Apache server, you must use special commands in your .htaccess
  • if you use Windows, it becomes even more complicated

This is why many use the wrong redirection.

To our aid, however, comes Google, which can usually recognize when webmasters use the wrong redirect and understand when they mean Redirect 301 instead of 302. Luckily for us, Google does not have to legally follow what it is told, otherwise, it would be a very confusing search engine! This practice is put in place for the user in order to guarantee him the best search result, in fact, if a 302 is found that is to be handled as Redirect 301, the search engine acts in this way:

  • no longer indexes the old URL
  • does not consider the new URL as a duplicate
  • does not split traffic between URLs and should not change SEO ranking

At this point the question arises as to whether Google handles 302s appropriately; unfortunately, we have no answer to this question. All we know is that Google aims to find errors made by developers and handle them appropriately.

When in doubt, use the right redirect.

If you have to move a page or a website permanently, it is correct to use a 301 redirect. Using 302 would mean telling search engines to keep the old domain or page indexing, at the expense of the new position. In the past, 302 redirects were used as a form of prevention from “Google aging delays”, but it remains an antiquated practice that is now ineffective.

If you are worried about losing your ranking as a result of a 301 redirect, the solution is not to change the domain name. As in the real world, when a company changes its name it seems there is something it wants to hide, Google applies the same logic. When the name is changed, it will make you start from scratch so that you can prove you are competent in your field and later be recommended by Google.

In summary, how to make a redirect with respect to types?

REDIRECT 301 REDIRECT 302
It is used when :
  • Do you want to move a page or a site permanently
  • Do you want to make a protocol change
  • You want to redirect the domains in your possession to one of them
  • You want to move a page, a site temporarily
  • You put the site or a page under maintenance
Evita that users are faced with the error 404 (Page not found) that users are faced with the error 404 (Page not found)
URL Only the new URL is considered, and the old one is forgotten Both URLs are kept active
Traffic and ranking
  • Traffic is taken to the only remaining URL
  • SEO and positioning efforts are not lost
  • A change of domain name can lead to changes in ranking
  • Traffic is broken down by URL
  • No major changes in SEO
  • In case a 302 redirect is mistakenly used instead of a 301 redirect, Google usually corrects the error

Optimise your website with SEO. Download the free guide now and find out how to do a 301 redirect

seo copywriting ebook guide

 

How to do a 301 Redirect

As mentioned above, doing a 301 redirect is useful when you want to signal to crawlers that a piece of content has been permanently changed, for instance, when:

  • You want to move a page or site permanently: e.g. from “www.questosito.it/vecchio” to “www.questosito.it/nuovo”.
  • You want to make a protocol change: e.g. from HTTP://… to HTTPS://…
  • You want to redirect domains with several extensions to just one of them: e.g. when I have all the extensions, I want to converge them into the main extension. So, in my case, I decided to point “www.questosito.it”, “www.questosito.org” and “www.questosito.net” to “www.questosito.com”.
  • Change the URL from “www” to without “www”.

There are two methods I propose to implement redirection:

  1. .htaccess files: for both Apache and Windows servers
  2. WordPress Plug-in: Redirection

Learn how a page or site redirect works and acquire the skills to do it

SEO SPECIALIST COURSE PROGRAM

HTACCESS files

The .htaccess file comes to our aid when we need to carry out a redirection of any kind. If you are a beginner, I recommend going straight to the plug-in, whereas if you are somewhat familiar with programs and codes: let’s get started!

N.B. All the cases that will be reported only work for Apache servers; if you use a Windows server, we propose an IIS-based solution.

The .htaccess file is the configuration file of the hosting on which your site is hosted, and to start working on how to do a redirect with .htaccess is necessary:

  • Find and download the .htaccess file from your server, this will require an FTP program
  • Immediately back up your .htaccess file
  • Save the .htaccess file with the extension .txt: The reason why you need to save the .htaccess.txt file is that some operating systems and FTP applications are not able to read .htaccess. Once you have loaded the htaccess.txt file, you can rename it as .htaccess.
  • Then add your redirect and upload the new version of your .htaccess.txt file

Depending on your requirements, there will be different codes to add in the .htaccess file, below are the most commonly used codes.

Pointing one page to another

301 redirect /what-you-need-to-change/ http://www.onthissite.it/with-what-you-did-new/

The structure of how to do such a redirect is as follows:- Redirect type: Redirect 3xx- Insert only the part to be changed, not including the part that goes from the HTTP to the extension: /what-you-need-to-change/- Add a space-Enter the new complete URL: http://www.onthissite.it/with-what-you-did-new/

Redirecting the old domain to the new one

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.olddomain\.com$ RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L].

RewriteCond %{HTTP_HOST} !^olddomain\.com$ RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L].

Redirect from old domain to new subdomain

RewriteEngine on RewriteRule ^(.*)$ http://www.your-new-domain.com/$1 [R=301,L].

Redirect from old subdomain to new subdomain

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^subdomain.old.com$

RewriteRule ^(.*)$ http://subdomain.newdomain.com/$1 [R=301,L].

RewriteCond %{HTTP_HOST} ^www.subdomain.olddomain.com$

RewriteRule ^(.*)$ http://subdomain.newdomain.com/$1 [R=301,L].

Redirect the new folder to the old one

RewriteRule ^oldfolder/(.*)$ /newfolder/$1 [R=301,NC,L].

Make a redirect within the same folder pointing to a different domain

Redirect 301 /folder http://www.newdomain.com/samefolder
Redirect from “WWW” to without “WWW”

The usefulness of this best practice lies in the fact that very often versions of the same page or site that have the www and those without are considered duplicates. By pointing one towards the other, you give the crawler the official version of the domain and avoid duplication.

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC].

RewriteRule ^(.*)$ http://%1/$1 [R=301,L].

In addition to these cases, there may be many others. If your case does not fall among them and you are not able to write code yourself, use a site that allows you to generate your own redirect code.

The best and most widely used is htaccessredirect.net.

Download the new free Chat-GPT guide and discover how it can help you with SEOchatgpt ebook

WINDOWS SERVER

To be able to implement a Redirect on a Windows server, it will be necessary to have IIS (Internet Information System) installed. With reference to versions 6 and 7, the steps to do a 301 Redirect with regard to the individual page and the entire site are explained.

IIS 6 

REDIRECTING A SINGLE FILE
  1. Open IIS Manager and position the website
  2. Right-click on the file you want to redirect and click on the properties
  3. Change the tick on “Redirect to a URL”.
  4. Under “Redirect to: ” write the new URL in the box
  5. Put a tick on “Permanent redirection for this resource” (will result in an HTTP status code: HTTP/1.1 301 Permanently Moved)
REDIRECTING AN ENTIRE SITE
  1. Open IIS Manager and position the website
  2. Right-click on the file you wish to redirect and click on the properties
  3. Select the “Home Directory” Tab
  4. Change the tick on “Redirect to a URL”.
  5. Under “Redirect to: ” write the new URL in the box
  6. Put a tick on “Permanent redirection for this resource” (will result in an HTTP status code: HTTP/1.1 301 Permanently Moved)

IIS7

REDIRECTING A SINGLE FILE
  1. Open IIS Manager and place the website under the sites
  2. Right-click on the site and always choose “switch to content viewing”.
  3. On the right-hand side place the file you want to redirect
  4. Right-click on the file and choose “switch to feature view”.
  5. NB: Check that the correct file name is displayed at the top of the screen
  6. Under the ISS section, open “HTTP Redirect”.
  7. Put a tick on “Request redirection to this destination and don’t forget to type in the new URL”
  8. Change the status code to “Permanent 301”.
  9. Click Apply (will result in an HTTP status code: HTTP/1.1 301 Moved Permanently)
REDIRECTING AN ENTIRE SITE
  1. Open IIS Manager and place the website under the sites
  2. NB: Check that the correct site name is displayed at the top of the screen
  3. Under the ISS section, open “HTTP Redirect”.
  4. Put a tick on “Request redirection to this destination and don’t forget to type in the new URL”
  5. Change the status code to “Permanent 301”.
  6. Click Apply (will result in an HTTP status code: HTTP/1.1 301 Moved Permanently)

WordPress Plugin: REDIRECTION

If you have created your site with WordPress, you are in luck because WordPress itself has developed a plug-in that makes it easy to make redirects, it is called “Redirection”. How to do a redirect with Redirection?

  • First, you have to download the plug-in so that it is placed on your site’s noticeboard
  • Once installed you will find Redirection in the “Tools” sectioninstall redirection dashboard
  • Simply click on Redirection and the screen shown in the picture will open. From here, you can enter the old URL to be replaced in the “Start URL” and the new one to replace the old one in the “Finish URL”.departure url in screen
  • Once you have inserted the links click on “Add Redirect” and you will see the Redirect you have just created appear at the top. If you do not see the Redirect appear, it means you have not created it and it is not working.

add redirect in the settings

  • If everything went well, you can now go and change some settings related to your Redirect. Simply click on Edit and then on the small wheel on the left of “Undo”.

modify related settings

  • Other entries will open, allowing you to change the type of match, its match, and the type of redirect.
    • Match Type, allows you to choose the type of match you wish to apply:
      • URL only
      • URL and login status
      • URL and referrer
      • URL and cookies
      • URL and HTTP Header
      • URL and custom filter
    • Based on the “when match” type you tell the redirection to redirect to:
      • URL
      • Random post
      • pass-through: i.e. hiding the URL change from the user
      • Error 404
      • Do nothing
    • Finally, you specify the Redirect to be used by means of the drop-down list that opens next to “HTTP Code”. You can choose between 301, 302, 307, and 308.

I hope you found this page helpful in learning how to do a redirect and make your website perform according to SEO best practices. If you want to learn more, also check out our WordPress and Website Creation Course.

Better manage your website with the right SEO practices. Contact us for a personal consultation by filling in the form below