How to use 301 redirect and 302 redirect

In the life of an SEO, it necessarily becomes a point to fix the missing URLs error such as 404 errors to make it more readable, both for engines or users. We must fight more or less with the .htaccess file located in the root of the site or within a folder.

Today we will therefore look at the file a bit barbaric but so useful.

The .htaccess file, what is it?

This is a file that gives instructions to the server, it shows commands to follow. In practice, it is thanks to him that we can protect our pages with passwords or we can manage the different error pages (404, 401, 403, etc.). It also allows redirection pages and URL rewriting. Today I am here to tell you about the redirection, whether permanent or temporary.

For information, This file is called .htaccess , we can not open the htaccess any site from our browser for security reasons. .htaccess file is always placed in your server and have hidden attribute, so if you want to access it you have to select show hidden files. You may download it, edit it and replace with the earlier one in server.

301-302 redirect

The 301 redirect

The so-called permanent redirection is used mostly in a site redesign when some pages are moved or deleted. 301 redirect will resolve 404 error (page not found) and also retain the link juice made to this page.

The 301 redirect can be done with plain text (no coding is required).

Method with text is the easiest to achieve. Clearly, we tell .htaccess file what to command, lets have a look:

RedirectPermanent /old-page.html http://www.newdomain.com/new-page.html

RedirectPermanent /folder/ http://www.newdomain.com/new-folder/

RedirectPermanent / http://www.newdomain.com/

How these examples work:

  • The first line allows you to redirect a single page
  • The second line redirects a complete (with its subfolders and pages)
  • The third line allows you to redirect a complete domain to a new domain

Note: Do not forget to make a space after the “RedirectPermanent” and before the final URL.

The 302 redirect

302 redirect is used for temporary redirection which is rarely used. It can be when you edit a page directly online and you do not want the user to sees the work or when you for example marketing on your site. Google understands that the redirection is not definitive, it does not give the weight of the links to the new page.

Like a 301, a temporary redirect can be done with text or regular expressions. Again you will see only the version with text only. And the method is the same as before, we’ll just change what they say to the server (a temporary redirect and not a permanent redirect).

Redirect /old-page.html http://www.newdomain.com/new-page.html

Redirect /old-folder http://www.newdomain.com/new-folder

Redirect /http://www.newdomain.com/

There may be no need for me to explain the effects of these redirection.. you already know that.

About admin

The Discussion

  1. saharsh jain says:

    i used a website’s given code to remove the redirect of 302 but now i am losing my alexa rank due to it as all my visitors are on .in domain and has rank of 52 lakh ,
    plz help should i revert to redirect ie. enable 302 in mine ,if yes then hoe to re-enable it.
    if no then plz tell me will alexa count y blog .com and .in as same
    because http://saharshjain.blogspot.com/- on alexa has no ranking check yourself
    while http://saharshjain.blogspot.in has good rank
    plz help reply asap

Leave a Reply