Skip to content

Instantly share code, notes, and snippets.

@bahiirwa
Forked from johnalarcon/.htaccess
Created March 19, 2020 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahiirwa/0ec6bb228623bdb5e24b00f8b3a5d6a6 to your computer and use it in GitHub Desktop.
Save bahiirwa/0ec6bb228623bdb5e24b00f8b3a5d6a6 to your computer and use it in GitHub Desktop.
Directives for the ClassicPress .htaccess file. These directives can be copied into your exisitng .htaccess file, but they are not intended to overwrite other directives that may already be present. Read the comment before each directive below, and you'll be fine!
# Code Potent's official .htaccess directives to make your ClassicPress site ROCK!
# Prevent directory browsing.
Options -Indexes
# Enable rewrite engine - you may already have these 2 lines... don't duplicate, if so.
RewriteEngine On
RewriteBase /
# Force SSL connection to everything (URLs, images, scripts, styles, etc)
# Replace www.yourdomain.com with your own domain. If your domain does not
# use the www, you can leave that part off.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
# Enable browser compression for a huge page-speed increase!
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
</ifmodule>
# Enable "Expires Headers"
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment