Skip to content

Instantly share code, notes, and snippets.

@johnalarcon
Last active March 24, 2020 20:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnalarcon/9c6327cba59e723153c89fb74c63ce6b to your computer and use it in GitHub Desktop.
Save johnalarcon/9c6327cba59e723153c89fb74c63ce6b 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