Skip to content

Instantly share code, notes, and snippets.

@chesio
Created January 10, 2018 16:56
Show Gist options
  • Save chesio/2768c0ff601065d4d36348839f2e719a to your computer and use it in GitHub Desktop.
Save chesio/2768c0ff601065d4d36348839f2e719a to your computer and use it in GitHub Desktop.
.htaccess rules for Cachify on WordPress installations in subdirectory at EDIS vhost
# BEGIN Cachify
<IfModule mod_rewrite.c>
RewriteEngine on
# Set hostname directory
RewriteCond %{ENV:HTTPS} =on
RewriteRule .* - [E=CACHIFY_HOST:https-%{HTTP_HOST}]
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* - [E=CACHIFY_HOST:%{HTTP_HOST}]
# Set subdirectory
RewriteCond %{REQUEST_URI} /$
RewriteRule .* - [E=CACHIFY_DIR:%{REQUEST_URI}]
RewriteCond %{REQUEST_URI} ^$
RewriteRule .* - [E=CACHIFY_DIR:/]
# gzip
RewriteRule .* - [E=CACHIFY_SUFFIX:]
<IfModule mod_mime.c>
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=CACHIFY_SUFFIX:.gz]
AddType text/html .gz
AddEncoding gzip .gz
</IfModule>
# Main rules
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-content/cache)/.*
RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
RewriteCond %{DOCUMENT_ROOT}/wordpress/wp-content/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html -f
RewriteRule .* /wordpress/wp-content/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html%{ENV:CACHIFY_SUFFIX} [L]
</IfModule>
# END Cachify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment