Quick TipWritten on

Render a static HTML file from PHP

Let's say you have a full static site and you need a single file to handle a submission or an API call or something.

Here is the php part -- Let's say it's called index.php:


  if (!empty( $_POST )) {
      // Handle the business side of the request here ...

      // Render the thanks page

  // Render the form or stuff

And the .htaccess part for apache users is straight forward:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]