
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
# ----------------------------------------------------------------------
# Set www to non-www redirect
# ----------------------------------------------------------------------

 <IfModule mod_rewrite.c>
    RewriteCond %{HTTP_HOST} ^www\.nimbus.in [NC]
    RewriteRule ^(.*)$ http://nimbus.in/$1 [L,R=301]
</IfModule>


# ------------------------------------------------------------------------------
# | Better website experience                                                  |
# ------------------------------------------------------------------------------

# Force IE to render pages in the highest available mode in the various
# cases when it may not: http://hsivonen.iki.fi/doctype/ie-mode.pdf.

<IfModule mod_headers.c>
    Header set X-UA-Compatible "IE=edge"
    # `mod_headers` can't match based on the content-type, however, we only
    # want to send this header for HTML pages and not for the other resources
    <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
        Header unset X-UA-Compatible
    </FilesMatch>
</IfModule>


<IfModule mod_headers.c>
	# No caching for dynamic files
	<filesMatch "\.(php|cgi|pl|html|htm|xml)$">
		Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
		Header set Pragma "no-cache"
	</filesMatch>

	# 1 MONTH
	<filesMatch "\.(jpg|jpeg|png|gif|swf|ico|js|css|pdf|flv|txt)$">
		Header set Cache-Control "max-age=2419200, must-revalidate"
	</filesMatch>

</IfModule>

# Prevent mobile network providers from modifying the website's content.
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5.

# <IfModule mod_headers.c>
#    Header set Cache-Control "no-transform"
# </IfModule>


<IfModule mod_mime.c>

  # Audio
    AddType audio/mp4                                   m4a f4a f4b
    AddType audio/ogg                                   oga ogg opus
	AddType audio/wav                                   wav
	AddType audio/wma                                   wma
	AddType audio/x-realaudio                           ra ram
	AddType audio/midi                                  mid midi
	AddType audio/mpeg                                  mp3 m4a

  # Images
  	AddType image/bmp                                   bmp
	AddType image/gif                                   gif
	AddType image/jpeg                                  jpg jpeg jpe
	AddType image/tiff                                  tif tiff
	AddType image/png                                   png

  # Data interchange
    AddType application/json                            json map
    AddType application/ld+json                         jsonld

  # JavaScript
    # Normalize to standard type.
    # http://tools.ietf.org/html/rfc4329#section-7.2
    AddType application/javascript                      js

  # Video
    AddType video/mp4                                   mp4 m4v f4v f4p
    AddType video/ogg                                   ogv
    AddType video/webm                                  webm
    AddType video/x-flv                                 flv
	AddType video/asf                                   asf asx wax wmv wmx
	AddType video/avi                                   avi
	AddType video/divx                                  divx
	AddType video/quicktime                             mov qt
	AddType video/mpeg                                  mpeg mpg mpe

  # Web fonts
    AddType application/font-woff                       woff
    AddType application/vnd.ms-fontobject               eot

    # Browsers usually ignore the font MIME types and sniff the content,
    # however, Chrome shows a warning if other MIME types are used for the
    # following fonts.
    AddType application/x-font-ttf                      ttc ttf
    AddType font/opentype                               otf

    # Make SVGZ fonts work on iPad:
    # https://twitter.com/FontSquirrel/status/14855840545
    AddType     image/svg+xml                           svg svgz
    AddEncoding gzip                                    svgz

  # Other
    AddType application/octet-stream                    safariextz
    AddType application/x-chrome-extension              crx
    AddType application/x-opera-extension               oex
    AddType application/x-shockwave-flash               swf
    AddType application/x-web-app-manifest+json         webapp
    AddType application/x-xpinstall                     xpi
    AddType application/xml                             atom rdf rss xml
    AddType image/webp                                  webp
    AddType image/x-icon                                ico cur
    AddType text/cache-manifest                         appcache manifest
    AddType text/vtt                                    vtt
    AddType text/x-component                            htc
    AddType text/x-vcard                                vcf
	AddType text/plain                                  txt
	AddType text/richtext                               rtf rtx

  # Compressed Files
	AddType application/x-tar                           tar
	AddType application/x-gzip                          gz gzip
	AddType application/zip                             zip

  # Applications
	AddType application/msword                          doc docx
	AddType application/x-msdownload                    exe
	AddType application/pdf                             pdf
	AddType application/vnd.ms-access                   mdb
	AddType application/vnd.ms-powerpoint               pot pps ppt pptx
	AddType application/vnd.ms-excel                    xla xls xlsx xlt xlw
	AddType application/vnd.ms-project                  mpp

</IfModule>

# Since we're sending far-future expires headers (see below), ETags can
# be removed: http://developer.yahoo.com/performance/rules.html#etags.

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

FileETag None

<IfModule mod_expires.c>

    ExpiresActive on
    ExpiresDefault                                      "access plus 1 month"

  # CSS
    ExpiresByType text/css                              "access plus 1 year"

  # Data interchange
    ExpiresByType application/json                      "access plus 0 seconds"
    ExpiresByType application/ld+json                   "access plus 0 seconds"
    ExpiresByType application/xml                       "access plus 0 seconds"
    ExpiresByType text/xml                              "access plus 0 seconds"
    ExpiresByType text/xsd                              "access plus 1 month"
    ExpiresByType text/xsl                              "access plus 1 month"

  # Favicon (cannot be renamed!) and cursor images
    ExpiresByType image/x-icon                          "access plus 1 month"

  # HTML components (HTCs)
    ExpiresByType text/x-component                      "access plus 1 month"

  # HTML
    ExpiresByType text/html                             "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript                "access plus 1 year"

  # Manifest files
    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
    ExpiresByType text/cache-manifest                   "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg                             "access plus 1 month"
    ExpiresByType audio/x-realaudio                     "access plus 1 month"
    ExpiresByType audio/wav                             "access plus 1 month"
    ExpiresByType audio/wma                             "access plus 1 month"
    ExpiresByType audio/ogg                             "access plus 1 month"
    ExpiresByType audio/midi                            "access plus 1 month"
    ExpiresByType audio/mpeg                            "access plus 1 month"
    ExpiresByType image/gif                             "access plus 1 month"
    ExpiresByType image/jpeg                            "access plus 1 month"
    ExpiresByType image/png                             "access plus 1 month"
    ExpiresByType image/tiff                            "access plus 1 month"
    ExpiresByType image/bmp                             "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"
    ExpiresByType video/asf                             "access plus 1 month"
    ExpiresByType video/avi                             "access plus 1 month"
    ExpiresByType video/divx                            "access plus 1 month"
    ExpiresByType video/quicktime                       "access plus 1 month"
    ExpiresByType video/mpeg                            "access plus 1 month"
    ExpiresByType video/x-flv                           "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom+xml                  "access plus 1 hour"
    ExpiresByType application/rss+xml                   "access plus 1 hour"

  # Web fonts
    ExpiresByType application/font-woff                 "access plus 1 month"
    ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
    ExpiresByType application/x-font-ttf                "access plus 1 month"
    ExpiresByType font/opentype                         "access plus 1 month"
    ExpiresByType image/svg+xml                         "access plus 1 month"

  # Application files
    ExpiresByType application/msword                    "access plus 1 month"
    ExpiresByType application/pdf                       "access plus 1 month"
    ExpiresByType application/vnd.ms-access             "access plus 1 month"
    ExpiresByType application/vnd.ms-write              "access plus 1 month"
    ExpiresByType application/vnd.ms-excel              "access plus 1 month"
    ExpiresByType application/vnd.ms-powerpoint         "access plus 1 month"
    ExpiresByType application/vnd.ms-project            "access plus 1 month"
    ExpiresByType text/richtext                         "access plus 1 month"
    ExpiresByType text/plain                            "access plus 1 month"
    ExpiresByType application/x-msdownload              "access plus 1 month"
    ExpiresByType application/x-shockwave-flash         "access plus 1 month"
	ExpiresByType application/java                      "access plus 1 month"

  # Compressed files
    ExpiresByType application/x-tar                     "access plus 1 month"
    ExpiresByType application/zip                       "access plus 1 month"
    ExpiresByType application/x-gzip                    "access plus 1 month"

</IfModule>

# ------------------------------------------------------------------------------
# | UTF-8 encoding                                                             |
# ------------------------------------------------------------------------------

# Use UTF-8 encoding for anything served as `text/html` or `text/plain`.
AddDefaultCharset UTF-8

# Force UTF-8 for certain file formats.
<IfModule mod_mime.c>
    AddCharset utf-8 .atom .css .js .json .jsonld .rss .vtt .webapp .xml
</IfModule>

<IfModule mod_headers.c>
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
    Header append Vary Cookie env=!dont-vary
</IfModule>

# ----------------------------------------------------------------------
# Instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
# https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>


<IfModule mod_deflate.c>

    # Force compression for mangled headers.
    # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
    <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
        </IfModule>
    </IfModule>

    # Compress all output labeled with one of the following MIME-types
    # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
    #  and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
    #  as `AddOutputFilterByType` is still in the core directives).
    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE application/atom+xml \
                                      application/javascript \
                                      application/json \
                                      application/ld+json \
                                      application/rss+xml \
                                      application/vnd.ms-fontobject \
                                      application/x-font-ttf \
                                      application/x-web-app-manifest+json \
                                      application/xhtml+xml \
                                      application/xml \
                                      font/opentype \
                                      image/svg+xml \
                                      image/x-icon \
                                      text/css \
                                      text/html \
                                      text/plain \
                                      text/richtext \
                                      text/x-component \
                                      text/xml

		# Don't compress binaries
		SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|iso|tar|bz2|sit|rar) no-gzip dont-vary

		# Don't compress images
		SetEnvIfNoCase Request_URI .(?:gif|jpe?g|jpg|ico|png)  no-gzip dont-vary

		# Don't compress PDFs
		SetEnvIfNoCase Request_URI .pdf no-gzip dont-vary

		# Don't compress flash files (only relevant if you host your own videos)
		SetEnvIfNoCase Request_URI .(?:flv|swf) no-gzip dont-vary

		# Drop problematic browsers
		BrowserMatch ^Mozilla/4 gzip-only-text/html
		BrowserMatch ^Mozilla/4\.0[678] no-gzip
		BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
		BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
		# Opera occasionally pretends to be IE with "Mozilla/4.0"
		BrowserMatch \bOpera !no-gzip
	</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /blog/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond /home/nimbus/public_html/blog/wp-content/cache/static%{REQUEST_URI}index.html -f
RewriteCond %{HTTP_USER_AGENT} "!(iPhone|iPod|aspen|dream|BB10|BlackBerry|IEMobile|Opera Mobi|Opera Mini|palmos|webos|Googlebot-Mobile)" [NC]
RewriteCond %{HTTP_USER_AGENT} "!(?=.*?\bandroid\b)(?=.*?\bmobile\b).*$" [NC]
RewriteCond %{HTTP_COOKIE} !\bwordpress_logged_in_4947929efabb69b8bb70ce25cdd58482=
RewriteCond %{HTTP_COOKIE} !\bcomment_author_4947929efabb69b8bb70ce25cdd58482=
RewriteCond %{HTTP_COOKIE} !\bcomment_author_email_4947929efabb69b8bb70ce25cdd58482=
RewriteCond %{HTTP_COOKIE} !\bwp-postpass_4947929efabb69b8bb70ce25cdd58482=
RewriteCond %{HTTP_COOKIE} !\bam_regulars_4947929efabb69b8bb70ce25cdd58482=
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{THE_REQUEST} ^GET
RewriteRule ^ /blog/wp-content/cache/static%{REQUEST_URI}index.html [L]

RewriteCond /home/nimbus/public_html/blog/wp-content/sitemaps%{REQUEST_URI} -f
RewriteRule \.xml(\.gz)?$ /blog/wp-content/sitemaps%{REQUEST_URI} [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress
