AddDefaultCharset UTF-8

# --- Prevent querying of certain files / file types ---
<FilesMatch "^(composer\.json|composer\.lock|package\.json|yarn\.lock|.*\.env)$">
    Require all denied
</FilesMatch>

# --- Add MIME-type and charset for Markdown documentation ---
<FilesMatch "\.(md|markdown)$">
    AddType text/markdown .md .markdown
    AddCharset utf-8 .md .markdown
</FilesMatch>

# --- Block directories without index file ---
<IfModule mod_autoindex.c>
    Options -Indexes
</IfModule>

# --- Define error pages (the pages are available after installation) ---
ErrorDocument 403 /403/
ErrorDocument 404 /404/

### Sym8 / based on Symphony 2.84.x ###
Options +SymLinksIfOwnerMatch -Indexes

<IfModule !mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE No
</IfModule>

<IfModule mod_rewrite.c>

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

    RewriteEngine on
    RewriteBase "/<!-- REWRITE_BASE -->"

    ### SECURITY - Protect crucial files
    RewriteRule ^(.*)\.(bak|config|ini|log|sh|swp|inc|old|orig)$ - [F]
    RewriteRule ^manifest/(.*)$ - [F]
    RewriteRule ^workspace/(pages|utilities)/(.*)\.xsl$ - [F]
    RewriteRule ^(.*)\.sql$ - [F]
    RewriteRule (^|/)\. - [F]

    ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
    RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
    RewriteRule .* - [S=14]

    ### CHECK FOR TRAILING SLASH - Will ignore files
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ $1/ [L,R=301]

    ### URL Correction
    RewriteRule ^(symphony/)?index.php(/.*/?) $1$2 [NC]

    ### ADMIN REWRITE
    RewriteRule ^symphony\/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^symphony(\/(.*\/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}   [NC,L]

    ### FRONTEND REWRITE - Will ignore files and folders
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}    [L]

</IfModule>
######
