{"id":367710,"date":"2021-11-15T19:00:00","date_gmt":"2021-11-15T16:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/whats-the-difference-between-301-and-302-redirects-cloudsavvy-it\/"},"modified":"2021-11-15T19:00:00","modified_gmt":"2021-11-15T16:00:00","slug":"whats-the-difference-between-301-and-302-redirects-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/whats-the-difference-between-301-and-302-redirects-cloudsavvy-it\/","title":{"rendered":"#What\u2019s the Difference Between 301 and 302 Redirects? \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a411875c84ab\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a411875c84ab\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-the-difference-between-301-and-302-redirects-cloudsavvy-it\/#302_Is_Temporary_301_Is_Permanent\" >302 Is Temporary, 301 Is Permanent<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-the-difference-between-301-and-302-redirects-cloudsavvy-it\/#How_Does_This_Affect_SEO\" >How Does This Affect SEO?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-the-difference-between-301-and-302-redirects-cloudsavvy-it\/#How_To_Set_Up_Redirects_in_Nginx\" >How To Set Up Redirects in Nginx<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-the-difference-between-301-and-302-redirects-cloudsavvy-it\/#How_to_Set_Up_Redirects_in_Apache\" >How to Set Up Redirects in Apache<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What\u2019s the Difference Between 301 and 302 Redirects? \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure style=\"width: 1400px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage wp-image-4633 size-full\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/04\/9614db4d.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/04\/9614db4d.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/04\/9614db4d.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"301 redirect illustration\" width=\"1400\" height=\"664\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-illustration\/illustration-301-redirect-concept-1136154221\" data-credittext=\"duangphorn wiriya\/Shutterstock\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-illustration\/illustration-301-redirect-concept-1136154221\">duangphorn wiriya\/Shutterstock<\/a><\/span><\/figcaption><\/figure>\n<p>If you\u2019ve moved your content around, it\u2019s best to redirect old broken links to the working location. There are two types of redirects\u2014302, used for testing, and 301, which is permanent, and best for SEO.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"302_Is_Temporary_301_Is_Permanent\"><\/span>302 Is Temporary, 301 Is Permanent<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Both redirect types achieve the same effect. When a user attempts to access a redirected resources (for example, the HTTP version of an HTTPS link), the web server sends a 301 or 302 response code to the user\u2019s browser, along with a link to the intended destination. The user\u2019s browser will then im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely make another request to the correct page, effectively redirecting them.<\/p>\n<p>The difference lies in what h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ens the second time a user visits that page. If you\u2019re serving a 302 redirect, the browser will see this as temporary. In the HTTPS example, the browser will continue to make requests to the insecure HTTP version of the page, and the web server will continue to send 302 response codes each time.<\/p>\n<p>This is bad for your site\u2019s performance, as a user will have to make more round <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/trip-and-travel\/\" data-internallinksmanager029f6b8e52c=\"10\" title=\"Trip &amp; Travel\" target=\"_blank\" rel=\"noopener\">trip<\/a>s to the web server to get to the intended destination. To solve this, you can use a 301 redirect. When the browser tries to make a second request, it will check its cache and remember that the URL is supposed to be redirected, and automatically redirect without bothering the server. A 301 redirect is supposed to be sent out once, and redirect forever.<\/p>\n<p>This means a 301 redirect is very permanent. Chrome will remember one until the user clears the cache, which is a manual operation. If you accidentally made an incorrect 301 redirect, it could cause issues down the line, so you\u2019ll always want to test changes with a 302 redirect first to verify that it works, then deploy a 301 redirect.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_Does_This_Affect_SEO\"><\/span>How Does This Affect SEO?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Most of the time, search engines like Google will see a 301 redirect and update their search rankings accordingly. If you\u2019re changing domain names, you will want to 301 redirect your old domain\u2019s links to the new domain\u2019s pages. This will lead to your new domain replacing your old one in the search rankings, which is (probably) what you want.<\/p>\n<p>Ultimately, having to redirect your site probably won\u2019t hurt your SEO much. Between 90-99% of your sites ranking will transfer over when changing your entire domain name, so redirecting a few pages won\u2019t hurt at all. Note that this only applies to 301 redirects\u2014302 redirects are temporary, and won\u2019t have any immediate effect on your rankings, but can drag you down in the long run if you don\u2019t switch to 301.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_To_Set_Up_Redirects_in_Nginx\"><\/span>How To Set Up Redirects in Nginx<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In Nginx, you can implement redirects using the <code>rewrite<\/code>\u00a0directive. This will match a string with a regular expression\u00a0and redirect the user to a modified URL. If you simply want to redirect an old page to a new page, you can select the page name and replace it with a rewrite:<\/p>\n<pre>server {&#13;\n  server_name www.example.com;&#13;\n  rewrite ^\/old_page.html$ new_page.html redirect;&#13;\n}<\/pre>\n<p>Then, if you want to make it a permanent redirect, replace \u201credirect\u201d with \u201cpermanent\u201d:<\/p>\n<pre>rewrite ^\/old_page.html$ new_page.html permanent;<\/pre>\n<p>You can use the same syntax to match multiple pages. For example, if you wanted to map an entire domain to a new domain, you could use:<\/p>\n<pre>server {&#13;\n  server_name olddomain.com;&#13;\n  rewrite ^\/(.*)$ https:\/\/newdomain.com\/$1 permanent;&#13;\n}<\/pre>\n<p>For redirecting HTTP to HTTPS, you\u2019ll instead want to use a listen block on port 80 that will redirect all traffic by manually serving a 301:<\/p>\n<pre>server {&#13;\n  listen 80;&#13;\n&#13;\n  server_name example.com;&#13;\n  return 301 https:\/\/example.com$request_uri;&#13;\n}<\/pre>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_to_Set_Up_Redirects_in_Apache\"><\/span>How to Set Up Redirects in Apache<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For Apache, the setup is simple as well. For basic redirects, you can use the <code>Redirect<\/code>\u00a0directive, which takes two arguments\u2014the old page, and the new page.<\/p>\n<pre>Redirect \/oldpage https:\/\/www.example.com\/newpage<\/pre>\n<p>This defaults to a 302 redirect, but you can make it permanent by using \u201c<code>Redirect 301<\/code>\u201c.<\/p>\n<p>The Redirect directive takes manual parameters, but you can use <code>RedirectMatch<\/code>\u00a0to match URLs with regular expressions. For example, to remap a folder like <code>\/img<\/code> to a subdomain, you can use:<\/p>\n<pre>RedirectMatch ^\/img\/(.*)$ http:\/\/media.example.com\/$1<\/pre>\n<p>To redirect HTTP to HTTPS, you\u2019ll want to use:<\/p>\n<pre>RewriteEngine On &#13;\nRewriteCond %{SERVER_PORT} 80 &#13;\nRewriteRule ^(.*)$ https:\/\/www.yourdomain.com\/$1 [R,L]<\/pre>\n<p>This defaults to 302, but you can make it permanent by setting the return code at the end:<\/p>\n<pre>RewriteRule ^(.*)$ https:\/\/www.yourdomain.com\/$1 [R=301,L]<\/pre>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/1635\/whats-the-difference-between-301-and-302-redirects\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What\u2019s the Difference Between 301 and 302 Redirects? \u2013 CloudSavvy IT&#8221; duangphorn wiriya\/Shutterstock If you\u2019ve moved your content around, it\u2019s best to redirect old broken links to the working location. There are two types of redirects\u2014302, used for testing, and 301, which is permanent, and best for SEO. 302 Is Temporary, 301 Is Permanent Both&#8230;<\/p>\n","protected":false},"author":1,"featured_media":367711,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/04\/9614db4d.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-367710","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/367710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=367710"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/367710\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/367711"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=367710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=367710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=367710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}