title: url rewrite rule for a single page application
body: <p>I have a single page application that is based on a index.php that loads all the css and js needed. Then in a div inside the page I load all the application functionalities using jQuery <code>.load()</code>. Each time I load something via the menu with this function I also do:</p>
  
  <pre><code>window.history.pushState({},null,url);
  </code></pre>
  
  <p>to write an entry in the browser history that will look like:</p>
  
  <pre><code>https://example.org/creditmanager/index.php?area=masterdata&amp;sub=pf
  </code></pre>
  
  <p>every page will have an unique match of area and sub. Everything works fine besides back and forth buttons in the navigation bar. If I hit back the browser will change the url in the address bar to the previous entry in the history <strong>but will not reload the page since the url has not changed</strong> (or at least this is my best guess of why). If I hit reload after hitting back I get the right page in the right way. So I was thinking about enhancing my .htaccess for this app with a rewrite rule that will say that this example url:</p>
  
  <pre><code>https://example.org/creditmanager/index.php?area=masterdata&amp;sub=pf
  </code></pre>
  
  <p>will become:</p>
  
  <pre><code>https://example.org/creditmanager/masterdata/pf
  </code></pre>
  
  <p>This way the previous url may look as</p>
  
  <pre><code>https://example.org/creditmanager/masterdata/pg
  </code></pre>
  
  <p>and the browser will force the reload on back button.
  I have found an example of a rule that can be close to mine in <a href="https://stackoverflow.com/questions/22435825/mod-rewrite-rule-for-a-url-with-multiple-get-variables">this SO question</a>  but I need help to elaborate the concept to my goal (the first subdir is the area and the second is the sub in the url query).
  Is anyone of you so kind to help me to elaborate the task?
  So far I have only a rewrite condition in my site .conf file in apache that will redirect http:// requests to https:// and no .htaccess yet.</p>
  
  <p><strong>EDIT</strong>
  Tried to add this directly to the conf file for apache:</p>
  
  <pre><code>&lt;Directory /var/www/jdev/creditmanager/ &gt;
      RewriteEngine On
      RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&amp;page=$2
      RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&amp;page=$2
  &lt;/Directory&gt;
  </code></pre>
  
  <p><em>Note that the app root is in /var/www/jdev/ while the index.php is in the /creditmanager subdir</em>
  Thanks!</p>