#-------------------------------------------------------------------------------
#                                  HTACCESS
#-------------------------------------------------------------------------------

# Signature serveur
ServerSignature Off

Header unset Cookie
Header unset Set-Cookie

# -------------------------------------
#            REDIRECTIONS
# -------------------------------------


<IfModule mod_rewrite.c>

  RewriteEngine On

  RewriteRule "^robots.txt$" "robots.txt" [L]

  # Redirige http vers https
  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://lagencepigment.com/$1 [R=301,L]

  # Redirige sans les trois www
  RewriteCond %{HTTP_HOST} !^lagencepigment\.com$ [NC]
  RewriteRule ^(.*)$ http://lagencepigment.com/$1 [R=301,L]

  # Redirige vers url sans slash
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$ /$1 [L,R=301]

  # Redirige vers url française si pas de langue spécifié
  RewriteCond %{HTTP:Accept-Language} ^fr [NC]
  RewriteRule ^$ /fr [L,R=301]


  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

  # Page 404
  ErrorDocument 404 /404.php

</IfModule>



# -------------------------------------
#           REGLES DE CACHE
# -------------------------------------

<IfModule mod_expires.c>
  ExpiresActive On

  # Images
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/jpg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"

  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"

  # Fonts
  AddType application/vnd.ms-fontobject .eot
  AddType application/x-font-ttf .ttf
  AddType application/x-font-opentype .otf
  AddType application/x-font-woff .woff
  AddType application/x-font-woff2 .woff2

  ExpiresByType application/x-font-ttf "access plus 1 year"
  ExpiresByType application/x-font-opentype "access plus 1 year"
  ExpiresByType application/x-font-woff "access plus 1 year"
  ExpiresByType application/x-font-woff2 "access plus 1 year"

  # Favicon
  AddType image/x-icon .ico
  ExpiresByType image/ico "access plus 1 year"

</IfModule>

<IfModule mod_headers.c>

  <FilesMatch "\\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "max-age=2592000, public"
  </FilesMatch>

  <FilesMatch "\\.(css)$">
    Header set Cache-Control "max-age=604800, public"
  </FilesMatch>

  <FilesMatch "\\.(js)$">
    Header set Cache-Control "max-age=216000, private"
  </FilesMatch>

  <FilesMatch "\\.(x?html?|php)$">
    Header set Cache-Control "max-age=600, private, must-revalidate"
  </FilesMatch>

</IfModule>
