# Turn mod_rewrite on
<IfModule mod_rewrite.c>
 
    RewriteEngine On
    RewriteBase /  
    ### Canonicalize codeigniter URLs  
    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301] 
    # Enforce www
    # If you have subdomains, you can add them to
    # the list using the "|" (OR) regex operator

  RewriteCond %{HTTPS} off [OR]
	RewriteCond %{HTTP_HOST} ^www\.automania-inc\.ca [NC]
    RewriteRule ^(.*)$ https://automania-inc.ca/$1 [R=301,L]
 
    ### 
    # Removes access to the system folder by users.
    # Additionally this will allow you to create a System.php controller,
    # previously this would not have been possible.
    # 'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
 
    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

 # BEGIN Compress text files
<ifModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
# END Compress text files
 
# BEGIN Expire headers
<ifModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 2 months"
  ExpiresByType image/x-icon "access plus 2 months"
  ExpiresByType image/jpeg "access plus 2 months"
  ExpiresByType image/png "access plus 2 months"
  ExpiresByType image/gif "access plus 2 months"
  ExpiresByType application/x-shockwave-flash "access plus 2 months"
  ExpiresByType text/html "access plus 600 seconds"
  ExpiresByType application/xhtml+xml "access plus 600 seconds" 
  
    # CSS and JavaScript
  #ExpiresByType application/javascript "access plus 1 year"
  <filesMatch "\.(js)$"> 
    ExpiresDefault A29030400 
  </filesMatch>

<filesMatch "\.(css)$"> 
    ExpiresDefault "access plus 2 months" 
  </filesMatch>
   # ExpiresByType text/css "access plus 1 year"

</ifModule>
# END Expire headers
 
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
  <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "public"
  </filesMatch>
  <filesMatch "\.(css)$">
    Header set Cache-Control "public"
  </filesMatch>
  <filesMatch "\.(js)$">
    Header set Cache-Control "private"
  </filesMatch>
  <filesMatch "\.(x?html?|php)$">
    Header set Cache-Control "private, must-revalidate"
  </filesMatch>
</ifModule>
# END Cache-Control Headers
 
# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off 
 