What is 301 and 302 redirect?
Both 301 and 302 are HTTP status codes that are returned to your browser as a response HTTP status.
So, what 301 and 302 means to web browser?
301 status code also known as 301 redirect is a permanent redirect which is used to specify that the requested resource is moved to new location.
For example: If you try to access https://modernpathshala.com/Article/2053/how-to-configure-robots-txt-file12345 then web server returns with HTTP response with status code 301 and redirect url https://modernpathshala.com/Article/2053/how-to-configure-robots-txt-file means that the requested resource has been moved to https://modernpathshala.com/Article/2053/how-to-configure-robots-txt-file location permanently. Henceforth, browser/client requests for the url returned with response with status 301 as shown in below diagram:
302 status code is a temporary redirect to a requested resource.
301 vs 302 redirect
Both 301 and 302 redirect are used to redirect requested resource to another resource but both of them has different impact on SEO.
In 301 redirect all the attributes of the requested page will be passed to redirected page which are:
Hence it is known as permanent redirect.
Whereas in 302 redirect, the attributes of the requested page are not passed to the redirected page.