title: Redirecting to a different URL upon refresh
body: <p>So I want my page to redirect to a different page when the user refreshes the page. I want the user to be redirected to <code>index.html</code> from <code>gettingstarted.html</code> when he/she refreshes the page.</p>
  
  <p>CODE:</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      //meta, seo stuff
  
      &lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
     //body stuff
  
     //below is just a script that redirects to gettingstarted.html upon first visit
  
    &lt;script type="text/javascript"&gt;
  
      function redirect(){
      var thecookie = readCookie('doRedirect');
      if(!thecookie){window.location = 'http://domain.tld/gettingstarted.html';
      }}function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name){var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i &lt; ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}window.onload = function(){redirect();createCookie('doRedirect','true','999');}
  
    &lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>gettingstarted.html</p>
  
  <p>Pretty much the same thing as <code>index.html</code></p>
  
  <p>I tried Googling but I kept getting the "Meta Refresh Tag" which in this case, is useless.</p>