Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 225 lines (155 sloc) 7.103 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 r…
paulirish authored
3
5a8f128 @paulirish apache tricks from perishablepress. also a no-www fix from jstnryan
paulirish authored
4 # Techniques in here adapted from all over, including:
5 # Kroc Camen: camendesign.com/.htaccess
6 # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
7
8
fdd14c1 @paulirish chrome frame and IE=edge as a header
paulirish authored
9 # Force the latest IE version, in various cases when it may fall back to IE7 mode
10 # github.com/rails/rails/commit/123eb25#commitcomment-118920
68c75c0 @paulirish remove duplicate cache manifest expires rules
paulirish authored
11 # 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
12 <IfModule mod_setenvif.c>
13 <IfModule mod_headers.c>
14 BrowserMatch MSIE ie
5274efc @paulirish simplify IE=edge chromeframe header setting, based on feedback from A…
paulirish authored
15 Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
fdd14c1 @paulirish chrome frame and IE=edge as a header
paulirish authored
16 </IfModule>
17 </IfModule>
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
18
9f9d6ee @paulirish Header append Vary Accept-Encoding - thx aaron peters.
paulirish authored
19 <IfModule mod_headers.c>
a77e668 @paulirish htaccess: Header append Vary User-Agent. thx Marco d'Itri
paulirish authored
20 # Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
21 # We need to inform proxies that content changes based on UA
cfbd24a @paulirish ifmodule headers for all those jerkfaces out there who dont have mod_…
paulirish authored
22 Header append Vary User-Agent
9f9d6ee @paulirish Header append Vary Accept-Encoding - thx aaron peters.
paulirish authored
23 # Cache control is set only if mod_headers is enabled, so that's unncessary to declare
cfbd24a @paulirish ifmodule headers for all those jerkfaces out there who dont have mod_…
paulirish authored
24 </IfModule>
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
25
6794dc3 @paulirish adding a bit mroe around the commented out CORS
paulirish authored
26 # Serve cross-domain ajax requests, disabled.
27 # enable-cors.org
b57c5c8 @paulirish minor. htaccess comment
paulirish authored
28 # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
6794dc3 @paulirish adding a bit mroe around the commented out CORS
paulirish authored
29 # <IfModule mod_headers.c>
30 # Header set Access-Control-Allow-Origin "*"
31 # </IfModule>
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be r…
paulirish authored
32
33
34
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
35
36 # allow access from all domains for webfonts
37 # alternatively you could only whitelist
38 # your subdomains like "sub.domain.com"
39
40 <FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
41 <IfModule mod_headers.c>
42 Header set Access-Control-Allow-Origin "*"
43 </IfModule>
44 </FilesMatch>
45
46
dc6978a formatting comments on .htaccess
Divya Manian authored
47 # audio
e2c718c @bentruyman According to RFC 5334 ( http://tools.ietf.org/html/rfc5334 ), the 'ogg'
bentruyman authored
48 AddType audio/ogg oga ogg
49
53652a9 @paulirish more mime-types
paulirish authored
50 # video
e2c718c @bentruyman According to RFC 5334 ( http://tools.ietf.org/html/rfc5334 ), the 'ogg'
bentruyman authored
51 AddType video/ogg ogv
5be6f1f @paulirish ico serving, webp, and other bits. thx iszak
paulirish authored
52 AddType video/mp4 mp4
53 AddType video/webm webm
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
54
6f01f43 @paulirish webfont serving types.
paulirish authored
55 # Proper svg serving. Required for svg webfonts on iPad
56 # twitter.com/FontSquirrel/status/14855840545
5be6f1f @paulirish ico serving, webp, and other bits. thx iszak
paulirish authored
57 AddType image/svg+xml svg svgz
58 AddEncoding gzip svgz
59
60 # webfonts
61 AddType application/vnd.ms-fontobject eot
62 AddType font/truetype ttf
63 AddType font/opentype otf
64 AddType font/woff woff
65
66 # assorted types
67 AddType image/vnd.microsoft.icon ico
68 AddType image/webp webp
69 AddType text/cache-manifest manifest
70 AddType text/x-component htc
71 AddType application/x-chrome-extension crx
6f01f43 @paulirish webfont serving types.
paulirish authored
72
73
280b11a @paulirish htaccess: serving of htc. fixes #55
paulirish authored
74
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
75
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
76 # allow concatenation from within specific js and css files
77
78 # e.g. Inside of script.combined.js you could have
79 # <!--#include file="jquery-1.4.2.js" -->
80 # <!--#include file="jquery.idletimer.js" -->
81 # and they would be included into this single file
82
e1f6987 @paulirish clarifications around the .combined. stuff
paulirish authored
83 # this is not in use in the boilerplate as it stands. you may
84 # choose to name your files in this way for this advantage
85 # or concatenate and minify them manually.
43abda8 @paulirish ServerSideIncludes disabled by default. Strengthened them up, too. fi…
paulirish authored
86 # Disabled by default.
87
88 # <FilesMatch "\.combined\.(js|css)$">
30e0d83 @paulirish cant do the SSI with .js files and NOEXEC. thx Philip von Bargen
paulirish authored
89 # Options +Includes
43abda8 @paulirish ServerSideIncludes disabled by default. Strengthened them up, too. fi…
paulirish authored
90 # SetOutputFilter INCLUDES
91 # </FilesMatch>
92
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be r…
paulirish authored
93
94
95
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
96
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
97 # gzip compression.
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
98 <IfModule mod_deflate.c>
99
6faf486 @paulirish updating reset css to account for some newer elements. v1.5.1 (minus …
paulirish authored
100 # html, txt, css, js, json, xml, htc:
7914e53 @paulirish js should be gzipped under a few different mimetypes. boilerplate doe…
paulirish authored
101 AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
102 AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
7db4787 @westonruter Using appropriate AddOutputFilterByType instead of incorrect(?) AddOu…
westonruter authored
103 AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
d9ce70d @paulirish etags removed. moving gzip outside of a <Location/> block
paulirish authored
104
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
105 # webfonts and svg:
154f5e1 @paulirish escaping fix in p3p section. (thx daniel harttman). fixed otfS typo. …
paulirish authored
106 <FilesMatch "\.(ttf|otf|eot|svg)$" >
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
107 SetOutputFilter DEFLATE
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
108 </FilesMatch>
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
109 </IfModule>
0bb9495 @paulirish new .htaccess template with some common settings.. still need to be r…
paulirish authored
110
111
9c1fbb3 @paulirish svg serving addressed for webfonts on ipad
paulirish authored
112
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
113 # these are pretty far-future expires headers
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
114 # they assume you control versioning with cachebusting query params like
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
115 # <script src="application.js?20100608">
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
116 # additionally, consider that outdated proxies may miscache
117 # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
118
119 # 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. mor…
paulirish authored
120 # "access plus 1 week" or so
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
121
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
122 <IfModule mod_expires.c>
6ce800b @paulirish tweaks to avoid apache errors a bit more.
paulirish authored
123 Header set Cache-Control "public"
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
124 ExpiresActive on
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
125
126 # Perhaps better to whitelist expires rules? Perhaps.
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
127 ExpiresDefault "access plus 1 month"
128
d019e26 fixed spelling error
Divya Manian authored
129 # cache.manifest needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
b6d10ae @paulirish cache manifest needs 0 expires (thx remy).
paulirish authored
130 ExpiresByType text/cache-manifest "access plus 0 seconds"
131
4e17c6d @paulirish expires rules mucking. other htaccess whitespace.
paulirish authored
132 # your document html
ec1bf21 @paulirish data (json/xml) should not be cached (good tip, SirFunk)
paulirish authored
133 ExpiresByType text/html "access plus 0 seconds"
134
135 # data
136 ExpiresByType text/xml "access plus 0 seconds"
137 ExpiresByType application/xml "access plus 0 seconds"
138 ExpiresByType application/json "access plus 0 seconds"
139
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
140
141 # rss feed
142 ExpiresByType application/rss+xml "access plus 1 hour"
143
144 # favicon (cannot be renamed)
145 ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
146
147 # media: images, video, audio
b59c1cc @adeelejaz Add Expires header for .gif
adeelejaz authored
148 ExpiresByType image/gif "access plus 1 month"
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
149 ExpiresByType image/png "access plus 1 month"
150 ExpiresByType image/jpg "access plus 1 month"
151 ExpiresByType image/jpeg "access plus 1 month"
152 ExpiresByType video/ogg "access plus 1 month"
153 ExpiresByType audio/ogg "access plus 1 month"
154 ExpiresByType video/mp4 "access plus 1 month"
e24de7f @paulirish expires for webm. hattip kroc camen.
paulirish authored
155 ExpiresByType video/webm "access plus 1 month"
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
156
157 # webfonts
2c0dce9 @paulirish fix up mimetypes for expires on webfonts. thx Holek.
paulirish authored
158 ExpiresByType font/truetype "access plus 1 month"
159 ExpiresByType font/opentype "access plus 1 month"
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
160 ExpiresByType font/woff "access plus 1 month"
161 ExpiresByType image/svg+xml "access plus 1 month"
5a8f128 @paulirish apache tricks from perishablepress. also a no-www fix from jstnryan
paulirish authored
162 ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
163
4092e6c @paulirish fix .htaccess formatting to avoid errors. fixes #11
paulirish authored
164 # css and javascript
44e49f8 @paulirish more detail around filename revving aka cachebusting
paulirish authored
165 ExpiresByType text/css "access plus 1 month"
166 ExpiresByType application/javascript "access plus 1 month"
167 ExpiresByType text/javascript "access plus 1 month"
937fcf2 @paulirish updated htaccess. expires headers are better. better compression. mor…
paulirish authored
168 </IfModule>
1ca728c @paulirish p3p header for cookieable iframes (IE)
paulirish authored
169
170
171
9b5d916 @redoPop Make sure mod_deflate is enabled before attempting to use it.
redoPop authored
172
f5bc803 @redoPop Updated FileEtag directive per paulirish's comment here:
redoPop authored
173 # Since we're sending far-future expires, we don't need ETags for
174 # static content.
f33a07d @paulirish removing http:// from doc urls
paulirish authored
175 # developer.yahoo.com/performance/rules.html#etags
f5bc803 @redoPop Updated FileEtag directive per paulirish's comment here:
redoPop authored
176 FileETag None
08b7768 @redoPop Get your inodes the heck out of my ETags!
redoPop authored
177
178
179
180
401889b @paulirish apache config notes for iframe cookies
paulirish authored
181 # Allow cookies to be set from iframes (for IE only)
182 # If needed, uncomment and specify a path or regex in the Location directive
183
184 # <IfModule mod_headers.c>
185 # <Location />
154f5e1 @paulirish escaping fix in p3p section. (thx daniel harttman). fixed otfS typo. …
paulirish authored
186 # 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
187 # </Location>
188 # </IfModule>
1ca728c @paulirish p3p header for cookieable iframes (IE)
paulirish authored
189
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
190
430ee89 @paulirish forward www.example.com to example.com by default.
paulirish authored
191 # you probably want www.example.com to forward to example.com -- shorter URLs are sexier.
f33a07d @paulirish removing http:// from doc urls
paulirish authored
192 # no-www.org/faq.php?q=class_b
7827a90 @paulirish nerfing the rewrite rules with ifModule. thx meander
paulirish authored
193 <IfModule mod_rewrite.c>
194 RewriteEngine On
5a8f128 @paulirish apache tricks from perishablepress. also a no-www fix from jstnryan
paulirish authored
195 RewriteCond %{HTTPS} !=on
7827a90 @paulirish nerfing the rewrite rules with ifModule. thx meander
paulirish authored
196 RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
197 RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
198 </IfModule>
430ee89 @paulirish forward www.example.com to example.com by default.
paulirish authored
199
6ce800b @paulirish tweaks to avoid apache errors a bit more.
paulirish authored
200 # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
201 # e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
202 Options -MultiViews
203 # -Indexes will have Apache block users from browsing folders without a default document
204 # Options -Indexes
205
206
207
208 # custom 404 page
209 ErrorDocument 404 /404.html
210
211
212
d64e768 @paulirish default charset clarifications.
paulirish authored
213 # use utf-8 encoding for anything served text/plain or text/html
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
214 AddDefaultCharset utf-8
d64e768 @paulirish default charset clarifications.
paulirish authored
215 # force utf-8 for a number of file formats
216 AddCharset utf-8 .html .css .js .xml .json .rss
0b140cf @paulirish 404 document. lots of .htaccess work
paulirish authored
217
218
219
5a8f128 @paulirish apache tricks from perishablepress. also a no-www fix from jstnryan
paulirish authored
220 # We don't need to tell everyone we're apache.
221 ServerSignature Off
222
223
224
Something went wrong with that request. Please try again.