Skip to content

Instantly share code, notes, and snippets.

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 brookinsconsulting/a7aecefce2f676979634 to your computer and use it in GitHub Desktop.
Save brookinsconsulting/a7aecefce2f676979634 to your computer and use it in GitHub Desktop.
Example working virtual host mod_rewrite rules configuration for serving static cache by default. Tested with ezpublish5_community_project-2014.07.0-gpl-full
RewriteEngine On
#RewriteLog "/tmp/rewrite.log"
#RewriteLogLevel 5
#
# Static cache in eZ Publish
#
# No cache for http posts
RewriteCond %{REQUEST_METHOD} !^POST$
# Do not cache vhost admin
RewriteCond %{HTTP_HOST} !^admin.*$
# Non caching vhost for passing the static cache
RewriteCond %{HTTP_HOST} !^nocache.*$
#RewriteCond %{REMOTE_ADDR} !^::1$
# Do not cache server based request
RewriteCond %{HTTP_USER_AGENT} !^eZ\ Publish\ static\ cache\ generator$
# Redirect home page requests to static default siteaccess cache
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{DOCUMENT_ROOT}/var/ezwebin_site/static/ezecosystem/index\.html -f
RewriteRule ^/?$ %{DOCUMENT_ROOT}/var/ezwebin_site/static/ezecosystem/index\.html [L]
# No cache for http posts
RewriteCond %{REQUEST_METHOD} !^POST$
# Do not cache vhost admin
RewriteCond %{HTTP_HOST} !^admin.*$
# Non caching vhost for passing the static cache
RewriteCond %{HTTP_HOST} !^nocache.*$
# Do not cache server based request
RewriteCond %{HTTP_USER_AGENT} !^eZ\ Publish\ static\ cache\ generator$
# Redirect all other page requests to static default siteaccess cache
# Does the index.html exist in the static cache?
RewriteCond %{DOCUMENT_ROOT}/var/ezwebin_site/static/ezecosystem$1/index.html -f
# Rewrite to the static cache
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/var/ezwebin_site/static/ezecosystem$1/index.html [L]
# Default ezpublish rules go after this comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment