title: Display Homepage on 404 Error
body: <p>I am trying to redirect a 404 request to the homepage of our website which is simply index.php. An example URL that is receiving a 404 error message is this URL <a href="https://www.website.com/directory/page" rel="nofollow noreferrer">https://www.website.com/directory/page</a>. I tried adding the following line to my configuration file: <code>error_page 404 /index.php;</code>. When I did that, I no longer receive a 404 on <strong>HTTPS</strong> request. It displays the homepage as I hoped. But I am still getting a 404 error on <strong>HTTP</strong> requests. Any suggestions on how to get this to work on <strong>HTTP</strong> as well?</p>
  
  <p>I am currently running an NGINX server. Here is my part of my configuration file:</p>
  
  <pre><code>server {
      server_name acme.com;
      return 301 $scheme://www.acme.com$request_uri;
  }
  
  server {
      listen 80;
      server_name www.acme.com;
  
      #BEGIN SSL
      listen 443 ssl;
      ssl_certificate /etc/nginx/ssl/acme.com.chained.crt;
      ssl_certificate_key /etc/nginx/ssl/acme.com.key;
  
      # Makes for the most secure connections
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_prefer_server_ciphers on;
      ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
      #END SSL
  
      root /usr/share/nginx/html;
      index index.php index.html index.htm;
  
      location / {
          try_files $uri $uri/ $uri.html $uri.php?$query_string;
      }
  
      error_page 404 /index.php;
  
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  
  }
  </code></pre>