# BEGIN WP Rocket v3.2.2
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>

# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>

# Since we’re sending far-future expires, we don’t need ETags for static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None

<IfModule mod_alias.c>
<FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$">
<IfModule mod_headers.c>
Header set X-Powered-By "WP Rocket/3.2.2"
Header unset Pragma
Header append Cache-Control "public"
Header unset Last-Modified
</IfModule>
</FilesMatch>

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
<IfModule mod_headers.c>
Header unset Pragma
Header append Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>

# Expires headers (for better cache control)
<IfModule mod_expires.c>
	ExpiresActive on
	# Perhaps better to whitelist expires rules? Perhaps.
	ExpiresDefault                              "access plus 1 month"
	# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
	ExpiresByType text/cache-manifest           "access plus 0 seconds"
	# Your document html
	ExpiresByType text/html                     "access plus 0 seconds"
	# Data
	ExpiresByType text/xml                      "access plus 0 seconds"
	ExpiresByType application/xml               "access plus 0 seconds"
	ExpiresByType application/json              "access plus 0 seconds"
	# Feed
	ExpiresByType application/rss+xml           "access plus 1 hour"
	ExpiresByType application/atom+xml          "access plus 1 hour"
	# Favicon (cannot be renamed)
	ExpiresByType image/x-icon                  "access plus 1 week"
	# Media: images, video, audio
	ExpiresByType image/gif                     "access plus 4 months"
	ExpiresByType image/png                     "access plus 4 months"
	ExpiresByType image/jpeg                    "access plus 4 months"
	ExpiresByType image/webp                    "access plus 4 months"
	ExpiresByType video/ogg                     "access plus 1 month"
	ExpiresByType audio/ogg                     "access plus 1 month"
	ExpiresByType video/mp4                     "access plus 1 month"
	ExpiresByType video/webm                    "access plus 1 month"
	# HTC files  (css3pie)
	ExpiresByType text/x-component              "access plus 1 month"
	# Webfonts
	ExpiresByType application/x-font-ttf        "access plus 1 month"
	ExpiresByType font/opentype                 "access plus 1 month"
	ExpiresByType application/x-font-woff       "access plus 1 month"
	ExpiresByType application/x-font-woff2      "access plus 1 month"
	ExpiresByType image/svg+xml                 "access plus 1 month"
	ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
	# CSS and JavaScript
	ExpiresByType text/css                      "access plus 1 year"
	ExpiresByType application/javascript        "access plus 1 year"
</IfModule>
# Gzip compression
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don’t compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp|pdf)$ no-gzip dont-vary
</IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
		                          application/javascript \
		                          application/json \
		                          application/rss+xml \
		                          application/vnd.ms-fontobject \
		                          application/x-font-ttf \
		                          application/xhtml+xml \
		                          application/xml \
		                          font/opentype \
		                          image/svg+xml \
		                          image/x-icon \
		                          text/css \
		                          text/html \
		                          text/plain \
		                          text/x-component \
		                          text/xml
</IfModule>
<IfModule mod_headers.c>
Header append Vary: Accept-Encoding
</IfModule>
</IfModule>

# END WP Rocket

RewriteEngine On
RewriteBase /
#RewriteRule ^r(\d+)[-/].*[-/]s(\d+)-.*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
#RewriteRule ^r(\d+)[-/]s(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
#RewriteRule ^s(\d+)[-/].*[-/]r(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
#RewriteRule ^s(\d+)[-/]r(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
#RewriteRule ^.*[-/]s(\d+)[-/]r(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
#RewriteRule ^.*[-/]s(\d+)[-/].*[-/]r(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
#RewriteRule ^.*[-/]r(\d+)[-/].*[-/]s(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
#RewriteRule ^.*[-/]r(\d+)[-/]s(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
### Bloquear site.ru
RewriteCond %{HTTP_REFERER} site\.ru [NC]
RewriteRule .* - [F] 
### WebRTC
RewriteRule webrtc/sipml5(.*) /tools/sipml5$1 [L]
RewriteCond %{REQUEST_URI} /webrtc/([0-9]*[a-zA-Z]+)/? [NC]
RewriteRule webrtc /tools/webrtc.php [L]
RewriteRule webrtc/([a-zA-Z0-9]*) /tools/webrtc.php?n=$1 [L]
#RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000  
#RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]  
#RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]  
#RewriteRule .* /mantenimiento.html [R=503,L] 
RewriteRule ^index\.php$ - [L]
# Truco para poder hacer que segun el dominio, el rewritebase cambie
#RewriteCond %{HTTP_HOST} !^enlaza\.mx$
#RewriteRule . - [E=REWRITEBASE:/]
#RewriteCond %{HTTP_HOST} ^enlaza\.mx$
#RewriteRule . - [E=REWRITEBASE:/blog/]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ %{ENV:REWRITEBASE}$1wp-admin/ [R=301,L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-login$ %{ENV:REWRITEBASE}$1wp-login/ [R=301,L]
# Convertir entradas con fecha en entradas simples
RewriteRule ^20[01][0-9]/[0-9]{2}/[0-9]{2}/([0-9a-zA-Z\-]*).* $1 [R=301,L]
RewriteRule ^20[01][0-9]/[0-9]{2}/([^/]+).*$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# Proteger el wp-includes
# Block the include-only files.
<IfModule mod_rewrite.c>
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
#RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
<files wp-config.php>
order allow,deny
deny from all
</files>
# BEGIN WordPress
# BEGIN_AVADA_GZIP_OUTPUT
# Avada rules revision 2 - managed by Avada, manual edits are overwritten.
<IfModule mod_mime.c>
    # Report the type of the inner extension (.css, .js) and describe the outer
    # one as a transfer encoding instead of a content type of its own. Scoped to
    # asset extensions so that real .tar.gz downloads are left alone.
    <FilesMatch "\.(css|js|mjs|svg|json|xml|txt|html|vtt)\.gz$">
        RemoveType .gz
        AddEncoding gzip .gz
    </FilesMatch>
    <FilesMatch "\.(css|js|mjs|svg|json|xml|txt|html|vtt)\.br$">
        RemoveType .br
        AddEncoding br .br
    </FilesMatch>
</IfModule>
<IfModule mod_rewrite.c>
    # Needed in case no other block in this file switched the engine on.
    RewriteEngine On

    # Brotli first, it is the smaller of the two when the client takes it.
    # no-gzip / no-brotli stop the output filters compressing this a second time.
    RewriteCond %{HTTP:Accept-Encoding} \bbr\b
    RewriteCond %{REQUEST_FILENAME}\.br -f
    RewriteRule ^(.*)$ $1.br [QSA,L,E=no-gzip:1,E=no-brotli:1]

    RewriteCond %{HTTP:Accept-Encoding} \bgzip\b
    RewriteCond %{REQUEST_FILENAME}\.gz -f
    RewriteRule ^(.*)$ $1.gz [QSA,L,E=no-gzip:1,E=no-brotli:1]
</IfModule>
<IfModule mod_headers.c>
    # Proxies have to key these on the encoding that was negotiated.
    <FilesMatch "\.(gz|br)$">
        Header append Vary Accept-Encoding
    </FilesMatch>
</IfModule>
# END_AVADA_GZIP_OUTPUT

# BEGIN_AVADA_GZIP_COMPRESSION
# Avada rules revision 2 - managed by Avada, manual edits are overwritten.
<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/plain text/html text/xml text/css text/javascript
    AddOutputFilterByType BROTLI_COMPRESS application/xml application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType BROTLI_COMPRESS application/javascript application/x-javascript
    AddOutputFilterByType BROTLI_COMPRESS application/json application/ld+json application/manifest+json
    AddOutputFilterByType BROTLI_COMPRESS image/svg+xml image/x-icon image/vnd.microsoft.icon
    AddOutputFilterByType BROTLI_COMPRESS font/ttf font/otf application/vnd.ms-fontobject
</IfModule>

<IfModule mod_deflate.c>
    # text/javascript is the type that current Apache builds map .js to,
    # application/javascript is what older ones still use.
    AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript
    AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE application/javascript application/x-javascript
    AddOutputFilterByType DEFLATE application/json application/ld+json application/manifest+json
    AddOutputFilterByType DEFLATE image/svg+xml image/x-icon image/vnd.microsoft.icon
    AddOutputFilterByType DEFLATE font/ttf font/otf application/vnd.ms-fontobject
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On

    # There is deliberately no ExpiresDefault here. It would cover text/html as
    # well, and mod_expires replaces Cache-Control, which would override the
    # no-cache headers WordPress and WooCommerce send for logged in users, carts
    # and checkout. Only the types listed below are given a lifetime.

    # Images.
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/avif "access plus 1 year"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 month"

    # Fonts.
    ExpiresByType font/woff2 "access plus 1 year"
    ExpiresByType font/woff "access plus 1 year"
    ExpiresByType font/ttf "access plus 1 year"
    ExpiresByType font/otf "access plus 1 year"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 year"

    # Styles and scripts.
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"

    # Media.
    ExpiresByType audio/mpeg "access plus 1 month"
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"

    # Documents.
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/plain "access plus 1 month"

    # Feeds.
    ExpiresByType application/atom+xml "access plus 1 hour"
    ExpiresByType application/rss+xml "access plus 1 hour"

    # Data that has to stay fresh.
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType text/xml "access plus 0 seconds"
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/ld+json "access plus 0 seconds"
    ExpiresByType application/manifest+json "access plus 0 seconds"
    ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
    ExpiresByType text/cache-manifest "access plus 0 seconds"
</IfModule>
# END_AVADA_GZIP_COMPRESSION
