# No folder listings.
Options -Indexes

# Database dumps, notes, logs and local settings are never served.
<FilesMatch "\.(sql|md|log|bak|sh|lock|ini|pem)$|^config\.local\.php$">
  Require all denied
</FilesMatch>

# core/, page_components/, install/ and tools/ have their own .htaccess (never served).
RedirectMatch 404 /\.git

# Short addresses: /app/kirim_show runs kirim_show.php; an old address with
# ".php" (GET) is sent to the short one. Pages print short links
# (app/core/toza_url.php); the desktop does the same in desktop/router.php.
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteCond %{THE_REQUEST} \s(/[^\s?]*/)index\.php[\s?]
  RewriteRule ^ %1 [R=301,L,NE]
  RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteCond %{THE_REQUEST} \s(/[^\s?]*?)\.php[\s?]
  RewriteRule ^ %1 [R=301,L,NE]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^(.+)$ $1.php [L]
</IfModule>
