hoangweb
3/9/2018 - 9:22 AM

.htaccess

# PATHNAME 
# if http://www.example.com/page.html/pathinfo -> return 404?
# To enable pathname information in URLs
AcceptPathInfo On

# DEFAULT DIRECTORY INDEX PAGE
DirectoryIndex index.php index.html index.htm

##
## DIRECTORY INDEX LISTINGS
##
# Enable directory index listings
Options +Indexes
# Disable directory index listings
Options -Indexes

# enable “fancy” indexing, where the index listing shows filenames, their filesizes
IndexOptions +FancyIndexing
# or disable it
IndexOptions -FancyIndexing

##
## DATA COMPRESSION
## can reduce page load times and the amount of bandwidth your site uses
##

# enable data compression
<IfModule mod_deflate.c>
  <filesMatch "\.(js|css|html|php)$">
      SetOutputFilter DEFLATE
  </filesMatch>
  
  # use MIME types to specify which files to compress
  AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

##
## Headers
##
# set a header
<IfModule mod_headers.c>
  Header set Animal cow
  Header set Animal monkey
  # append to a header
  Header append Animal camel
  
  # edit a header: search-and-replace
  Header edit Animal "camel" "llama"
  
  # remove a header from an HTTP response
  Header unset Animal
  
</IfModule>

# to handle multiple HTTP requests
<IfModule mod_headers.c>
  Header set Connection keep-alive
</IfModule>

##
## cache
##

# define expiration intervals for different types of content
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/png "access 1 hour"
    ExpiresByType image/gif "access 1 hour"
    ExpiresByType image/jpeg "access 1 hour"
    ExpiresByType text/javascript "access 2 weeks"
    ExpiresByType text/css "access 2 months"
    ExpiresByType text/html "modification 4 hours"
    ExpiresDefault "access 2 days"
</IfModule>

# ETags to manage web caching behavior
# you might want to disable entity tags during site development or to test web caching
Header unset ETag
FileETag None