Skip to content

Instantly share code, notes, and snippets.

@skojin
Created February 3, 2010 19:31
Show Gist options
  • Save skojin/293929 to your computer and use it in GitHub Desktop.
Save skojin/293929 to your computer and use it in GitHub Desktop.
apache rewrite rules for rails cache_page in /public/cache directory
RewriteEngine On
# home page cache
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^/([^.]+)$
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
RewriteRule ^/[^.]+$ /cache/%1.html [QSA,L]
# general pages cache
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteRule ^/$ /cache/index.html [QSA,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment