Options -Indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Application code, command-line scripts, tests and data are never requested directly.
    RewriteRule ^(includes|templates|tests|bin|private-storage)(/|$) - [F,L]
    RewriteRule ^(config\.php|config\.example\.php|VERSION)$ - [F,L]

    RewriteRule ^go/([A-Za-z0-9_-]+)/?$ redirect.php?slug=$1 [L,QSA]
    RewriteRule ^download/([A-Za-z0-9_-]+)/?$ download.php?slug=$1 [L,QSA]
    RewriteRule ^api/count/([A-Za-z0-9_-]+)/?$ api/count.php?slug=$1 [L,QSA]
    RewriteRule ^api/count/([A-Za-z0-9_-]+)/json/?$ api/count.php?slug=$1&format=json [L,QSA]

    RewriteRule ^admin/?$ admin/index.php [L]
    RewriteRule ^admin/links/?$ admin/links.php [L]
    RewriteRule ^admin/links/create/?$ admin/link-create.php [L]
    RewriteRule ^admin/links/([A-Za-z0-9_-]+)/stats/?$ admin/link-stats.php?id=$1 [L,QSA]
    RewriteRule ^admin/links/([A-Za-z0-9_-]+)/?$ admin/link-edit.php?id=$1 [L,QSA]
    RewriteRule ^admin/settings/?$ admin/settings.php [L]
    RewriteRule ^admin/activity/?$ admin/activity.php [L]
</IfModule>

<IfModule mod_authz_core.c>
    <FilesMatch "^(config\.php|config\.example\.php|VERSION)$">
        Require all denied
    </FilesMatch>
</IfModule>
<IfModule !mod_authz_core.c>
    <FilesMatch "^(config\.php|config\.example\.php|VERSION)$">
        Order allow,deny
        Deny from all
    </FilesMatch>
</IfModule>
