Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 193 lines (128 sloc) 5.771 kb
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
1 # Apache configuration file
2 # httpd.apache.org/docs/2.2/mod/quickreference.html
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be revi...
paulirish authored
3
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
4 # Techniques in here adapted from all over,
5 # including Kroc Camen: camendesign.com/.htaccess
6
7
fdd14c1 @paulirish chrome frame and IE=edge as a header
paulirish authored
8 # Force the latest IE version, in various cases when it may fall back to IE7 mode
9 # github.com/rails/rails/commit/123eb25#commitcomment-118920
68c75c0 @paulirish remove duplicate cache manifest expires rules
paulirish authored
10 # Use ChromeFrame if it's installed for a better experience for the poor IE folk
fdd14c1 @paulirish chrome frame and IE=edge as a header
paulirish authored
11 <IfModule mod_setenvif.c>
12 <IfModule mod_headers.c>
13 BrowserMatch MSIE ie
5274efc @paulirish simplify IE=edge chromeframe header setting, based on feedback from Alex...
paulirish authored
14 Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
fdd14c1 @paulirish chrome frame and IE=edge as a header
paulirish authored
15 </IfModule>
16 </IfModule>
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
17
18
19 # hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
c9796ba @paulirish htaccess improvements
paulirish authored
20 # Disabled. Uncomment to serve cross-domain ajax requests
21 #<IfModule mod_headers.c>
22 # Header set Access-Control-Allow-Origin "*"
23 #</IfModule>
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be revi...
paulirish authored
24
25
26
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
27
28 # allow access from all domains for webfonts
29 # alternatively you could only whitelist
30 # your subdomains like "sub.domain.com"
31
32 <FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
33 <IfModule mod_headers.c>
34 Header set Access-Control-Allow-Origin "*"
35 </IfModule>
36 </FilesMatch>
37
38
53652a9 @paulirish more mime-types
paulirish authored
39 # video
641beda @paulirish webm mimetype. thx ken nordahl. fixes #31
paulirish authored
40 AddType video/ogg ogg ogv
41 AddType video/mp4 mp4
42 AddType video/webm webm
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
43
6f01f43 @paulirish webfont serving types.
paulirish authored
44 # Proper svg serving. Required for svg webfonts on iPad
45 # twitter.com/FontSquirrel/status/14855840545
46 AddType image/svg+xml svg svgz
47
48 # webfonts
49 AddType application/vnd.ms-fontobject eot
50 AddType font/ttf ttf
51 AddType font/otf otf
52 AddType font/x-woff woff
53
fcf8374 @paulirish correct serving of cache manifest
paulirish authored
54 AddType text/cache-manifest manifest
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
55
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
56 # allow concatenation from within specific js and css files
57
58 # e.g. Inside of script.combined.js you could have
59 # <!--#include file="jquery-1.4.2.js" -->
60 # <!--#include file="jquery.idletimer.js" -->
61 # and they would be included into this single file
62
e1f6987 @paulirish clarifications around the .combined. stuff
paulirish authored
63 # this is not in use in the boilerplate as it stands. you may
64 # choose to name your files in this way for this advantage
65 # or concatenate and minify them manually.
43abda8 @paulirish ServerSideIncludes disabled by default. Strengthened them up, too. fixes...
paulirish authored
66 # Disabled by default.
67
68 # <FilesMatch "\.combined\.(js|css)$">
69 # Options +IncludesNOEXEC
70 # SetOutputFilter INCLUDES
71 # </FilesMatch>
72
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be revi...
paulirish authored
73
74
75
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
76
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
77 # gzip compression.
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
78 <IfModule mod_deflate.c>
79
80 # html, xml, css, and js:
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
81 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json
d9ce70d @paulirish etags removed. moving gzip outside of a <Location/> block
paulirish authored
82
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
83 # webfonts and svg:
154f5e1 @paulirish escaping fix in p3p section. (thx daniel harttman). fixed otfS typo. (th...
paulirish authored
84 <FilesMatch "\.(ttf|otf|eot|svg)$" >
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
85 SetOutputFilter DEFLATE
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
86 </FilesMatch>
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
87 </IfModule>
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be revi...
paulirish authored
88
89
9c1fbb3 @paulirish svg serving addressed for webfonts on ipad
paulirish authored
90
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be revi...
paulirish authored
91
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
92 # these are pretty far-future expires headers
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
93 # they assume you control versioning with cachebusting query params like
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
94 # <script src="application.js?20100608">
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
95 # additionally, consider that outdated proxies may miscache
96 # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
97
98 # if you don't use filenames to version, lower the css and js to something like
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
99 # "access plus 1 week" or so
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
100
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
101 <IfModule mod_expires.c>
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
102 Header set cache-control: public
103 ExpiresActive on
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
104
105 # Perhaps better to whitelist expires rules? Perhaps.
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
106 ExpiresDefault "access plus 1 month"
107
b6d10ae @paulirish cache manifest needs 0 expires (thx remy).
paulirish authored
108 # cache.manifest needs re-reqeusts in FF 3.6 (thx Remy ~Introducing HTML5)
109 ExpiresByType text/cache-manifest "access plus 0 seconds"
110
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
111 # your document html
ec1bf21 @paulirish data (json/xml) should not be cached (good tip, SirFunk)
paulirish authored
112 ExpiresByType text/html "access plus 0 seconds"
113
114 # data
115 ExpiresByType text/xml "access plus 0 seconds"
116 ExpiresByType application/xml "access plus 0 seconds"
117 ExpiresByType application/json "access plus 0 seconds"
118
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
119
120 # rss feed
121 ExpiresByType application/rss+xml "access plus 1 hour"
122
123 # favicon (cannot be renamed)
124 ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
125
126 # media: images, video, audio
127 ExpiresByType image/png "access plus 1 month"
128 ExpiresByType image/jpg "access plus 1 month"
129 ExpiresByType image/jpeg "access plus 1 month"
130 ExpiresByType video/ogg "access plus 1 month"
131 ExpiresByType audio/ogg "access plus 1 month"
132 ExpiresByType video/mp4 "access plus 1 month"
133
134 # webfonts
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
135 ExpiresByType font/ttf "access plus 1 month"
136 ExpiresByType font/woff "access plus 1 month"
137 ExpiresByType image/svg+xml "access plus 1 month"
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
138
4092e6c @paulirish fix .htaccess formatting to avoid errors. fixes #11
paulirish authored
139 # css and javascript
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
140 ExpiresByType text/css "access plus 1 month"
141 ExpiresByType application/javascript "access plus 1 month"
142 ExpiresByType text/javascript "access plus 1 month"
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. more d...
paulirish authored
143 </IfModule>
1ca728c @paulirish p3p header for cookieable iframes (IE)
paulirish authored
144
145
146
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
147
f5bc803 @redoPop Updated FileEtag directive per paulirish's comment here:
redoPop authored
148 # Since we're sending far-future expires, we don't need ETags for
149 # static content.
f33a07d @paulirish removing http:// from doc urls
paulirish authored
150 # developer.yahoo.com/performance/rules.html#etags
f5bc803 @redoPop Updated FileEtag directive per paulirish's comment here:
redoPop authored
151 FileETag None
08b7768 @redoPop Get your inodes the heck out of my ETags!
redoPop authored
152
153
154
155
401889b @paulirish apache config notes for iframe cookies
paulirish authored
156 # Allow cookies to be set from iframes (for IE only)
157 # If needed, uncomment and specify a path or regex in the Location directive
158
159 # <IfModule mod_headers.c>
160 # <Location />
154f5e1 @paulirish escaping fix in p3p section. (thx daniel harttman). fixed otfS typo. (th...
paulirish authored
161 # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
401889b @paulirish apache config notes for iframe cookies
paulirish authored
162 # </Location>
163 # </IfModule>
1ca728c @paulirish p3p header for cookieable iframes (IE)
paulirish authored
164
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
165
430ee89 @paulirish forward www.example.com to example.com by default.
paulirish authored
166 # you probably want www.example.com to forward to example.com -- shorter URLs are sexier.
f33a07d @paulirish removing http:// from doc urls
paulirish authored
167 # no-www.org/faq.php?q=class_b
430ee89 @paulirish forward www.example.com to example.com by default.
paulirish authored
168 RewriteEngine On
169 RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
170 RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
171
172
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
173 # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist (e.g. “/blog/hello”)
f33a07d @paulirish removing http:// from doc urls
paulirish authored
174 # webmasterworld.com/apache/3808792.htm
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
175 Options -MultiViews
176 # -Indexes will have Apache block users from browsing folders without a default document
177 # Options -Indexes
178
179
180
181 # custom 404 page
182 ErrorDocument 404 /404.html
183
184
185
d64e768 @paulirish default charset clarifications.
paulirish authored
186 # use utf-8 encoding for anything served text/plain or text/html
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
187 AddDefaultCharset utf-8
d64e768 @paulirish default charset clarifications.
paulirish authored
188 # force utf-8 for a number of file formats
189 AddCharset utf-8 .html .css .js .xml .json .rss
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
190
191
192
Something went wrong with that request. Please try again.