title: How to redirect on NGINX and store original request as POST variable?
body: <p>I'm trying to set up a php site on NGINX. The functionality I'm going for is a way to have a section "expand" without reloading the page, but also being able to store the state in the URL. An example would be this:</p>
  
  <ol>
  <li>Click a button to expand a section</li>
  <li>The section name, say <em>resume</em>, would be put in the url: <a href="https://example.com/resume" rel="nofollow noreferrer">https://example.com/resume</a> <strong>but the site wouldn't reload</strong></li>
  <li>If the page is reloaded, the section is expanded by default</li>
  <li>The when a back button or (X) button is pressed, the url is reverted to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a> and the page returns to its original state (without reloading)</li>
  </ol>
  
  <p>I can already add to the url with history.state in my javascript, and I can get the section to expand on the press of a button, but I can't figure out the nginx configuration that will let me reroute all requests for <em>/resume</em> and a few other ones (like <em>/projects</em> and <em>/contact</em>) back to index.php and use the request as a variable in PHP.</p>
  
  <p>I'm pretty sure this would be possible with an .htaccess, but I am using NGINX and trying very hard to avoid using any sort of htaccess file.</p>
  
  <p>My current NGINX config is this:</p>
  
  <pre><code>server {
      server {
          root /var/www/example.com/html;
          index index.php index.html index.htm index.nginx-debian.html;
  
          server_name example.com www.example.com;
  
          location / {
                  try_files $uri $uri/ =404;
          }
  
          error_page 404 /404.html;
  
          location ~ \.php$ {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
          }
  
          location ~ /\.ht {
                  deny all;
          }
  }
  </code></pre>
  
  <p>Thank you!</p>