# DinePad Pro: the dashboard's files are served as they are; everything else
# (the API, the website, ordering pages, media) goes to index.php.
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Sign-in tokens reach PHP.
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # The site root goes to PHP: the website domains and a restaurant's
    # own domain open their pages there; otherwise PHP shows the dashboard.
    RewriteRule ^$ index.php [L]
    RewriteRule ^index\.html$ index.php [L]

    # Anything that is not a file of the dashboard goes to PHP.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

<IfModule mod_headers.c>
    # New releases show at once; the big Flutter engine files are cached.
    <FilesMatch "\.(html|js|mjs|json|wasm|otf|ttf|frag|symbols)$">
        Header set Cache-Control "no-cache"
    </FilesMatch>
    <If "%{REQUEST_URI} =~ m#^/canvaskit/#">
        Header set Cache-Control "public, max-age=2592000"
    </If>
</IfModule>
