# Apache configuration file # httpd.apache.org/docs/2.2/mod/quickreference.html # Note .htaccess files are an overhead, this logic should be in your Apache config if possible # httpd.apache.org/docs/2.2/howto/htaccess.html # Techniques in here adapted from all over, including: # Kroc Camen: camendesign.com/.htaccess # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/ # Sample .htaccess file of CMS MODx: modxcms.com ### ### If you run a webserver other than apache, consider: ### github.com/paulirish/html5-boilerplate-server-configs ### # ---------------------------------------------------------------------- # Better website experience for IE users # ---------------------------------------------------------------------- # Force the latest IE version, in various cases when it may fall back to IE7 mode # github.com/rails/rails/commit/123eb25#commitcomment-118920 # Use ChromeFrame if it's installed for a better experience for the poor IE folk BrowserMatch MSIE ie Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie # Because X-UA-Compatible isn't sent to non-IE (to save header bytes), # We need to inform proxies that content changes based on UA Header append Vary User-Agent # Cache control is set only if mod_headers is enabled, so that's unncessary to declare # ---------------------------------------------------------------------- # Cross-domain AJAX requests # ---------------------------------------------------------------------- # Serve cross-domain ajax requests, disabled. # enable-cors.org # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity # # Header set Access-Control-Allow-Origin "*" # # ---------------------------------------------------------------------- # Webfont access # ---------------------------------------------------------------------- # allow access from all domains for webfonts # alternatively you could only whitelist # your subdomains like "sub.domain.com" Header set Access-Control-Allow-Origin "*" # ---------------------------------------------------------------------- # Proper MIME type for all files # ---------------------------------------------------------------------- # audio AddType audio/ogg oga ogg # video AddType video/ogg ogv AddType video/mp4 mp4 AddType video/webm webm # Proper svg serving. Required for svg webfonts on iPad # twitter.com/FontSquirrel/status/14855840545 AddType image/svg+xml svg svgz AddEncoding gzip svgz # webfonts AddType application/vnd.ms-fontobject eot AddType font/truetype ttf AddType font/opentype otf AddType application/x-font-woff woff # assorted types AddType image/x-icon ico AddType image/webp webp AddType text/cache-manifest appcache manifest AddType text/x-component htc AddType application/x-chrome-extension crx AddType application/x-xpinstall xpi AddType application/octet-stream safariextz # ---------------------------------------------------------------------- # Allow concatenation from within specific js and css files # ---------------------------------------------------------------------- # e.g. Inside of script.combined.js you could have # # # and they would be included into this single file # this is not in use in the boilerplate as it stands. you may # choose to name your files in this way for this advantage # or concatenate and minify them manually. # Disabled by default. # # Options +Includes # SetOutputFilter INCLUDES # # ---------------------------------------------------------------------- # gzip compression # ---------------------------------------------------------------------- # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ 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 RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding # html, txt, css, js, json, xml, htc: FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/ FilterProvider COMPRESS DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/ FilterChain COMPRESS FilterProtocol COMPRESS change=yes;byteranges=no # Legacy versions of Apache AddOutputFilterByType DEFLATE text/html text/plain text/css application/json AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript AddOutputFilterByType DEFLATE text/xml application/xml text/x-component # webfonts and svg: SetOutputFilter DEFLATE # ---------------------------------------------------------------------- # Expires headers (for better cache control) # ---------------------------------------------------------------------- # these are pretty far-future expires headers # they assume you control versioning with cachebusting query params like #