Options -Indexes
<Files index.html>
    FileETag None
    <IfModule mod_headers.c>
        Header unset ETag
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
    </IfModule>
</Files>
<Files public-widget.html>
    Require all denied
</Files>
<Files public-playback.html>
    Require all denied
</Files>
<IfModule mod_headers.c>
    <FilesMatch "^userTrack.*\.(?:js|css)$">
        Header set Cache-Control "public, max-age=290304000, immutable"
    </FilesMatch>
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine on
    
    RewriteBase /
    # Public recording links use the replay bundle without the dashboard shell.
    RewriteCond %{REQUEST_URI} ^(.*/)?share/
    RewriteRule ^share/recording/([^/]+)/([0-9]+)/?$ %1server/public-recordings/view.php?domain=$1&client=$2 [L]
    # Agency public dashboard/widget links use their own minimal frontend.
    RewriteCond %{REQUEST_URI} ^(.*/)?share/
    RewriteRule ^share/(dashboard|widget)/([^/]+)/?$ %1server/public-shares/view.php?type=$1&slug=$2 [L]
    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # If we try to load a missing resource file, load it from folder root
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^.*\.(jpg|css|js|gif|png|ico|mp3|woff2)$ [NC]
    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
    RewriteRule .+?([^\/]*\.*)$ %2$1 [L]

    # Rewrite everything else to root index.html to allow html5 state links
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
    RewriteRule ^.*$ %2/ [QSA,L]
    # https://web.archive.org/web/20180401034514/http://www.zeilenwechsel.de/it/articles/8/Using-mod_rewrite-in-.htaccess-files-without-knowing-the-RewriteBase.html
 </IfModule>
