Apache - htaccess file

About

The .htaccess file is a an apache configuration file that you can find in a directory of your website.

The configuration defined in this file is only available for this directory and the sub-directories (not global except for the .htaccess file stored at the root of your website)

Example: Setting an header conditionally

If the mod_header is present, Apache can add/delete headers

Example in the root .htaccess file, with the cache control

# Cache File
<IfModule mod_headers.c>
    # WEEK
    <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
        Header set Cache-Control "max-age=604800, public"
    </FilesMatch>

    # WEEK
    <FilesMatch "\.(js|css|swf)$">
        Header set Cache-Control "max-age=604800"
    </FilesMatch>
</IfModule>

Powered by ComboStrap