Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 290 lines (211 sloc) 10.531 kb
d4bffaed »
2011-04-09 first commit
1 # Apache configuration file
2 # httpd.apache.org/docs/2.2/mod/quickreference.html
3
4 # Note .htaccess files are an overhead, this logic should be in your Apache config if possible
5 # httpd.apache.org/docs/2.2/howto/htaccess.html
6
7 # ----------------------------------------------------------------------
8 # Better website experience for IE users
9 # ----------------------------------------------------------------------
10
11 # Force the latest IE version, in various cases when it may fall back to IE7 mode
12 # github.com/rails/rails/commit/123eb25#commitcomment-118920
13 # Use ChromeFrame if it's installed for a better experience for the poor IE folk
14
15 <IfModule mod_setenvif.c>
16 <IfModule mod_headers.c>
17 BrowserMatch MSIE ie
18 Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
19 </IfModule>
20 </IfModule>
21
22 <IfModule mod_headers.c>
23 # Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
24 # We need to inform proxies that content changes based on UA
25 Header append Vary User-Agent
26 # Cache control is set only if mod_headers is enabled, so that's unncessary to declare
27 </IfModule>
28
29 # ----------------------------------------------------------------------
30 # Proper MIME type for all files
31 # ----------------------------------------------------------------------
32
33 # audio
34 AddType audio/ogg oga ogg
35
36 # video
37 AddType video/ogg ogv
38 AddType video/mp4 mp4
39 AddType video/webm webm
40
41 # Proper svg serving. Required for svg webfonts on iPad
42 # twitter.com/FontSquirrel/status/14855840545
43 AddType image/svg+xml svg svgz
44 AddEncoding gzip svgz
45
46 # webfonts
47 AddType application/vnd.ms-fontobject eot
48 AddType font/truetype ttf
49 AddType font/opentype otf
50 AddType application/x-font-woff woff
51
52 # assorted types
53 AddType image/x-icon ico
54 AddType image/webp webp
55 AddType text/cache-manifest appcache manifest
56 AddType text/x-component htc
57 AddType application/x-chrome-extension crx
58 AddType application/x-xpinstall xpi
59 AddType application/octet-stream safariextz
60
61 # ----------------------------------------------------------------------
62 # gzip compression
63 # ----------------------------------------------------------------------
64
65 <IfModule mod_deflate.c>
66
67 # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
68 <IfModule mod_setenvif.c>
69 <IfModule mod_headers.c>
70 SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s,?\s(gzip|deflate)?|X{4,13}|~{4,13}|-{4,13})$ HAVE_Accept-Encoding
71 RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
72 </IfModule>
73 </IfModule>
74
75 # html, txt, css, js, json, xml, htc:
76 <IfModule filter_module>
77 FilterDeclare COMPRESS
78 FilterProvider COMPRESS DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
79 FilterProvider COMPRESS DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
80 FilterChain COMPRESS
81 FilterProtocol COMPRESS change=yes;byteranges=no
82 </IfModule>
83
84 <IfModule !mod_filter.c>
85 # Legacy versions of Apache
86 AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
87 AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
88 AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
89 </IfModule>
90
91 # webfonts and svg:
92 <FilesMatch "\.(ttf|otf|eot|svg)$" >
93 SetOutputFilter DEFLATE
94 </FilesMatch>
95
96 </IfModule>
97
98
99
100 # ----------------------------------------------------------------------
101 # Expires headers (for better cache control)
102 # ----------------------------------------------------------------------
103
104 # these are pretty far-future expires headers
105 # they assume you control versioning with cachebusting query params like
106 # <script src="application.js?20100608">
107 # additionally, consider that outdated proxies may miscache
108 # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
109
110 # if you don't use filenames to version, lower the css and js to something like
111 # "access plus 1 week" or so
112
113 <IfModule mod_expires.c>
114 ExpiresActive on
115
116 # Perhaps better to whitelist expires rules? Perhaps.
117 ExpiresDefault "access plus 1 month"
118
119 # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
120 ExpiresByType text/cache-manifest "access plus 0 seconds"
121
122 # your document html
123 ExpiresByType text/html "access plus 0 seconds"
124
125 # data
126 ExpiresByType text/xml "access plus 0 seconds"
127 ExpiresByType application/xml "access plus 0 seconds"
128 ExpiresByType application/json "access plus 0 seconds"
129
130 # rss feed
131 ExpiresByType application/rss+xml "access plus 1 hour"
132
133 # favicon (cannot be renamed)
134 ExpiresByType image/x-icon "access plus 1 week"
135
136 # media: images, video, audio
137 ExpiresByType image/gif "access plus 1 month"
138 ExpiresByType image/png "access plus 1 month"
139 ExpiresByType image/jpg "access plus 1 month"
140 ExpiresByType image/jpeg "access plus 1 month"
141 ExpiresByType video/ogg "access plus 1 month"
142 ExpiresByType audio/ogg "access plus 1 month"
143 ExpiresByType video/mp4 "access plus 1 month"
144 ExpiresByType video/webm "access plus 1 month"
145
146 # htc files (css3pie)
147 ExpiresByType text/x-component "access plus 1 month"
148
149 # webfonts
150 ExpiresByType font/truetype "access plus 1 month"
151 ExpiresByType font/opentype "access plus 1 month"
152 ExpiresByType application/x-font-woff "access plus 1 month"
153 ExpiresByType image/svg+xml "access plus 1 month"
154 ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
155
156 # css and javascript
157 ExpiresByType text/css "access plus 2 months"
158 ExpiresByType application/javascript "access plus 2 months"
159 ExpiresByType text/javascript "access plus 2 months"
160
161 <IfModule mod_headers.c>
162 Header append Cache-Control "public"
163 </IfModule>
164
165 </IfModule>
166
167
168
169 # ----------------------------------------------------------------------
170 # ETag removal
171 # ----------------------------------------------------------------------
172
173 # Since we're sending far-future expires, we don't need ETags for
174 # static content.
175 # developer.yahoo.com/performance/rules.html#etags
176 FileETag None
177
178 # ----------------------------------------------------------------------
179 # Start rewrite engine
180 # ----------------------------------------------------------------------
181
182 # Turning on the rewrite engine is necessary for the following rules and features.
183
184 # <IfModule mod_rewrite.c>
185 # RewriteEngine On
186 # </IfModule>
187
188
189 # ----------------------------------------------------------------------
190 # Add/remove trailing slash to (non-file) URLs
191 # ----------------------------------------------------------------------
192
193 # Google treats URLs with and without trailing slashes separately.
194 # Forcing a trailing slash is usually preferred, but all that's really
195 # important is that one correctly redirects to the other.
196
197 # By default option 1 (force trailing slash) is activated.
198 # http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html
199 # http://www.alistapart.com/articles/slashforward/
200 # http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#url Trailing Slash Problem
201
202 # ----------------------------------------------------------------------
203
204 # Option 1:
205 # Rewrite "domain.com/foo -> domain.com/foo/"
206
207 # <IfModule mod_rewrite.c>
208 # RewriteCond %{REQUEST_FILENAME} !-f
209 # RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
210 # RewriteRule ^(.*)$ /$1/ [R=301,L]
211 # </IfModule>
212
213 # ----------------------------------------------------------------------
214
215 # Option 2:
216 # Rewrite "domain.com/foo/ -> domain.com/foo"
217
218 #<IfModule mod_rewrite.c>
219 # RewriteRule ^(.*)/$ /$1 [R=301,L]
220 #</IfModule>
221
222
223
224 # ----------------------------------------------------------------------
225 # Built-in filename-based cache busting
226 # ----------------------------------------------------------------------
227
228 # If you're not using the build script to manage your filename version revving,
229 # you might want to consider enabling this, which will route requests for
230 # /css/all.20110203.css to /res/all.css
231
232 # To understand why this is important and a better idea than all.css?v1231,
233 # read: github.com/paulirish/html5-boilerplate/wiki/Version-Control-with-Cachebusting
234
235 # Uncomment to enable.
236 # <IfModule mod_rewrite.c>
237 # RewriteCond %{REQUEST_FILENAME} !-f
238 # RewriteCond %{REQUEST_FILENAME} !-d
239 # RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
240 # </IfModule>
241
242
243
244 # ----------------------------------------------------------------------
245 # Prevent 404 errors for non-existing redirected folders
246 # ----------------------------------------------------------------------
247
248 # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
249 # e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
250
251 Options -MultiViews
252
253
254
255 # ----------------------------------------------------------------------
256 # custom 404 page
257 # ----------------------------------------------------------------------
258
259 # You can add custom pages to handle 500 or 403 pretty easily, if you like.
260 ErrorDocument 404 /404.html
261
262
263
264 # ----------------------------------------------------------------------
265 # UTF-8 encoding
266 # ----------------------------------------------------------------------
267
268 # use utf-8 encoding for anything served text/plain or text/html
269 AddDefaultCharset utf-8
270
271 # force utf-8 for a number of file formats
272 AddCharset utf-8 .html .css .js .xml .json .rss
273
274
275
276 # ----------------------------------------------------------------------
277 # A little more security
278 # ----------------------------------------------------------------------
279
280
281 # Block access to "hidden" directories whose names begin with a period. This
282 # includes directories used by version control systems such as Subversion or Git.
283 # <IfModule mod_rewrite.c>
284 # RewriteRule "(^|/)\." - [F]
285 # </IfModule>
57b48a45 »
2011-04-12 added missing apple-touch-icon
286
287 <Files ~ "\.inc$">
288 Order allow,deny
289 Deny from all
290 </Files>
Something went wrong with that request. Please try again.