SetEnv ALLOW_OVERWRITE On

<IfModule mod_rewrite.c>
    Options +FollowSymLinks

    RewriteEngine On
    # Tell PHP that the mod_rewrite module is ENABLED.
    SetEnv HTTP_MOD_REWRITE On

    # Example showing how to force HTTPS
    #RewriteCond %{HTTPS} !=on
    #RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,QSA,L,NE]

    # Correction : Bloquer l'accès aux fichiers à la racine (sauf index.php)
    # On vérifie que c'est un fichier, qu'on n'appelle pas explicitement index.php
    # et que la requête ne contient pas de slash (pour rester à la racine)
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !/index\.php$
    RewriteRule ^[^/]+$ - [F]

    #Remove index.php from URL
    RewriteCond $1 !^(index\.php|(.*)\.images|css|js|robots\.txt|favicon\.ico)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
</IfModule>
 
<IfModule !mod_rewrite.c> 
    # Without mod_rewrite, route 404's to the front controller
    SetEnv HTTP_MOD_REWRITE Off
    ErrorDocument 404 "Error : Module rewrite is not available. Please check your system with requirements.php"
 </IfModule>

<IfModule mod_headers.c>
    <FilesMatch "\.(php|xls|xlsx)$">
        Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform, must-revalidate"
        Header set Pragma "no-cache"
    </FilesMatch>
</IfModule>

<IfModule mod_headers.c>
    <IfModule mod_deflate.c>
        <IfModule mod_filter.c>
            AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
            AddOutputFilterByType DEFLATE application/javascript application/x-javascript
            AddOutputFilterByType DEFLATE application/json
            AddOutputFilterByType DEFLATE application/xml application/xhtml+xml
            AddOutputFilterByType DEFLATE application/rss+xml application/atom+xml
            AddOutputFilterByType DEFLATE image/svg+xml
        </IfModule>
    </IfModule>
</IfModule>

# Explicitly add MIMETYPE for fonts
<IfModule mod_mime.c>
    AddType font/ttf .ttf
    AddType font/eot .eot
    AddType font/otf .otf
    AddType font/woff .woff
    AddType font/woff2 .woff2   
</ifModule>
