title: Preserve previous page when URL is changed manually with $location
body: <p>I've got a function in my controller that changes the browser's URL but I need to preserve the real previous page when user clicks on back button.</p>
  
  <p>For example:</p>
  
  <p>User is in /home and navigate to /article1. When user scrolls in the page I change the URL, for example to /article2 using:</p>
  
  <pre><code>$location.path('article2');
  </code></pre>
  
  <p>But if the user presses the back browser button staying in /article2 the url change to /article1 and I really need to redirect the navigation to /home.</p>
  
  <p>I've used this code:</p>
  
  <pre><code>var previousPage = document.referrer; // Get the previous location on page load
  history.pushState({}, '', previousPage); // Alter the history adding the previous page
  </code></pre>
  
  <p>But it doesn't work because in the change of the url using $location, the history state is altered automatically.</p>
  
  <p>How can I preserve the navigation?</p>