Htaccess File


Header unset ETag
FileETag None

# Rewrite rules
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Redirect to domain without www.
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
  RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]

  # Same for HTTPS:
  RewriteCond %{HTTPS} on
  RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
  RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]

  # Remove .html from file names
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}.html -f
  RewriteRule ^(.*)$ $1.html

  # Ensure all directory URLs have a trailing slash.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !/$
  RewriteCond %{REQUEST_URI} !/[^/]*.[^/]+$
  RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]

  # Same for HTTPS:
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !/$
  RewriteCond %{REQUEST_URI} !/[^/]*.[^/]+$
  RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]

# Add Caching.
<FilesMatch ".(ico|jpg|jpeg|png|gif|js|css|swf)$">
    Header set Cache-Control "max-age=86400"

# Prevent viewing of htaccess file.
<Files .htaccess>
    order allow,deny
    deny from all

# Prevent directory listings
Options All -Indexes

# Compress if gzip is available
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css  application/x-javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html

# Fix spelling errors in URLs 
<IfModule mod_speling.c>
  CheckSpelling On

# Compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
Exit mobile version