Current File : /var/www/html/.htaccess |
# Disable Directory Listings for Security
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Tell the server that index.shtml is the main homepage file
DirectoryIndex index.shtml index.php index.html
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_expires.c>
# Turn on the Expires module
ExpiresActive On
# Default cache time is 1 month
ExpiresDefault "access plus 1 month"
# Cache images and media for 1 year
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Cache CSS and JavaScript for 1 month
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Cache fonts for 1 year
ExpiresByType application/font-woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
# HTML files should not be cached for long
ExpiresByType text/html "access plus 0 seconds"
</IfModule>
<IfModule mod_headers.c>
# More modern Cache-Control headers for greater control
# This tells browsers to check with the server if the file has changed after the specified time
<FilesMatch "\.(jpg|jpeg|png|webp|gif|svg|ico)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
<FilesMatch "\.(css|js)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\.(woff2|woff|eot|ttf)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
</IfModule>