Skip to content

Instantly share code, notes, and snippets.

@dennisreimann
Created September 6, 2012 14:30
Show Gist options
  • Save dennisreimann/3656874 to your computer and use it in GitHub Desktop.
Save dennisreimann/3656874 to your computer and use it in GitHub Desktop.
Uberspace htaccess for Rails apps
RewriteEngine On
RewriteBase /
# ensure the browser supports gzip encoding
RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]
# ensure correct Content-Type and add encoding header
<FilesMatch \.css\.gz$>
ForceType text/css
Header set Content-Encoding gzip
</lesMatch>
<FilesMatch \.js\.gz$>
ForceType text/javascript
Header set Content-Encoding gzip
</FilesMatch>
# cache assets like forever
<FilesMatch \.(js|css|gz|jpe?g|gif|png|ico)$>
Header unset ETag
FileETag None
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>
# maintenance mode
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$
RewriteCond /var/www/virtual/dreimann/rails/openid/current/public/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ - [redirect=503,last]
# let rails handle everything else
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://localhost:43860/$1 [P]
@ryanclark2
Copy link

test?

@Sh4kE
Copy link

Sh4kE commented Sep 19, 2014

test!

@fwolfst
Copy link

fwolfst commented Mar 16, 2016

This wasnt tested for a long period of time.

@okeefm
Copy link

okeefm commented Mar 5, 2017

https://gist.github.com/dennisreimann/3656874#file-htaccess-L13

This line should probably be </FilesMatch>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment