<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json
</IfModule>


<IfModule mod_headers.c>
	Header set X-XSS-Protection "1; mode=block"
    Header set X-Content-Type-Options nosniff
    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Allow-Headers "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Acai-Token"
</IfModule>


<FilesMatch "\.(vue)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "jue, 1 Jan 1970 00:00:00 GMT"
    </IfModule>
</FilesMatch>

#php_flag opcache.enable Off
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/webp "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType font/opentype "access 1 year"
ExpiresByType font/ttf "access 1 year"
ExpiresByType text/css "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 year"
ExpiresByType application/x-javascript "access 1 year"
ExpiresByType application/x-shockwave-flash "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/ld+json" \
                                  "application/manifest+json" \
                                  "application/rdf+xml" \
                                  "application/rss+xml" \
                                  "application/schema+json" \
                                  "application/vnd.geo+json" \
                                  "application/vnd.ms-fontobject" \
                                  "application/x-font-ttf" \
                                  "application/x-javascript" \
                                  "application/x-web-app-manifest+json" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "font/eot" \
                                  "font/opentype" \
                                  "image/bmp" \
                                  "image/svg+xml" \
                                  "image/vnd.microsoft.icon" \
                                  "image/x-icon" \
                                  "text/cache-manifest" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/vcard" \
                                  "text/vnd.rim.location.xloc" \
                                  "text/vtt" \
                                  "text/x-component" \
                                  "text/x-cross-domain-policy" \
                                  "text/xml"

</IfModule>

# Use HTTP Strict Transport Security to force client to use secure connections only
# Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

<Files ~ "\.tpl$">
    Order allow,deny
    Deny from all
</Files>


Options -Indexes
Options +FollowSymLinks
Options -MultiViews

DirectoryIndex index.php

ErrorDocument 404 /apartados.php
ErrorDocument 403 /403.php
ErrorDocument 400 /400.php
ErrorDocument 500 /500.php
ErrorDocument 401 /401.php

#php_value memory_limit 256M

<IfModule mod_rewrite.c>
# Activar RewriteEngine
    RewriteEngine on

    RewriteCond %{REQUEST_URI} /index.php
    RewriteRule ^(.+[^/])$ / [R=301,L]

    RewriteCond %{REQUEST_URI} /+[^\.]+$
    RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]


# FAVICON
    RewriteRule ^favicon.ico$ /template/estandar/icons/favicon.ico [L]

# SITEMAP Y ROBOTS
    RewriteRule ^sitemap\.xml /cms/sitemap.php [L]
    RewriteRule ^robots\.txt /cms/robots.php [L]

# IDIOMAS
    #RewriteRule ^es/(.*)$ /$1 [L]

# BLUR IMAGENES
    RewriteRule ^blur/([a-zA-Z0-9-_./]*)(.*)$ blur.php?imagen=$1 [L]

# APARTADOS
    RewriteRule ^apartados/([a-zA-Z0-9-_]*)/([0-9]+)\.html(.*)$ apartados.php?num=$2 [L]

# CONTENIDOS
    RewriteRule ^contenidos/([a-zA-Z0-9-_]*)/([0-9]+)\.html(.*)$ contenidos.php?familia=$2 [L]
    RewriteRule ^contenidos/([a-zA-Z0-9-_]*)/([a-zA-Z0-9-_]*)/([0-9]+)/([0-9]+)\.html(.*)$ contenidos.php?familia=$3&num=$4 [L]

# OTROS CONTENIDOS
    RewriteRule ^otros-contenidos/([a-zA-Z0-9-_]*)/([0-9]+)\.html(.*)$ otros_contenidos.php?num=$2 [L]

# CONTACTO
    RewriteRule ^contacto\.html(.*)$ contacto.php [L]

# CATEGORIAS
    RewriteRule ^categorias/([a-zA-Z0-9-_]*)/([0-9]+)\.html(.*)$ productos.php?categoria=$2

# PRODUCTOS
    RewriteRule ^productos/([a-zA-Z0-9-_]*)/([0-9]+)\.html(.*)$ productos.php?num=$2

# SERVICE WORKER
    RewriteRule ^sw.js$ lib/sw/sw.php [L]
    RewriteRule ^manifest.json$ lib/sw/manifest.php [L]
    RewriteRule ^template/estandar/js/sw-controller.js$ lib/sw/sw-controller.php [L]
    RewriteRule ^(.+)-hsh([A-Za-z0-9]+).(.+)$ $1.$3 [L]
    RewriteRule ^custom-builder-style.css cms/lib/plugins/builder_saas/replace_code.php?getStyle=1 [L]
    RewriteRule ^custom-builder-javascript.js cms/lib/plugins/builder_saas/replace_code.php?getJavascript=1 [L]

# CSS y JS
    RewriteRule ^template/estandar/css/main.css$ lib/recursos.php?fileType=css [L]
    RewriteRule ^template/estandar/js/main.js$ lib/recursos.php?fileType=js [L]


##############
# SLUG       #
##############

    #RewriteBase /dashboard-client/
    #RewriteRule ^index\.html$ - [L]
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule . /template/estandar/modulos/cuentadashboard_38o4db/index.html [L]

# Permitir acceso directo a la carpeta 2fa y sus archivos
RewriteCond %{REQUEST_URI} ^/2fa(/.*)?$
RewriteRule ^ - [L]

# ENLACES PERMANENTES
RewriteRule ^([a-zA-Z0-9-\/_]*)$ slug.php?enlace=$1&%{QUERY_STRING}&tipo=barra [L]

</IfModule>
