Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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]
@dennisreimann

This comment has been minimized.

Copy link
Owner Author

commented Oct 8, 2012

Test

@dennisreimann

This comment has been minimized.

Copy link
Owner Author

commented Dec 25, 2012

Test

@dennisreimann

This comment has been minimized.

Copy link
Owner Author

commented Dec 25, 2012

test

@tvdeyen

This comment has been minimized.

Copy link

commented Sep 8, 2013

test

@ryanclark2

This comment has been minimized.

Copy link

commented May 7, 2014

test?

@Sh4kE

This comment has been minimized.

Copy link

commented Sep 19, 2014

test!

@fwolfst

This comment has been minimized.

Copy link

commented Mar 16, 2016

This wasnt tested for a long period of time.

@okeefm

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.