summaryrefslogtreecommitdiff
path: root/apache2/conf.d/local-html5.conf
blob: 3007b1424a77aca873cf5193dda2c20229626fdb (plain)
  1. # Apache configuration file
  2. # httpd.apache.org/docs/2.2/mod/quickreference.html
  3. # Note .htaccess files are an overhead, this logic should be in your Apache config if possible
  4. # httpd.apache.org/docs/2.2/howto/htaccess.html
  5. # Techniques in here adapted from all over, including:
  6. # Kroc Camen: camendesign.com/.htaccess
  7. # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
  8. # Sample .htaccess file of CMS MODx: modxcms.com
  9. ###
  10. ### If you run a webserver other than Apache, consider:
  11. ### github.com/paulirish/html5-boilerplate-server-configs
  12. ###
  13. # ----------------------------------------------------------------------
  14. # Better website experience for IE users
  15. # ----------------------------------------------------------------------
  16. # Force the latest IE version, in various cases when it may fall back to IE7 mode
  17. # github.com/rails/rails/commit/123eb25#commitcomment-118920
  18. # Use ChromeFrame if it's installed for a better experience for the poor IE folk
  19. <IfModule mod_headers.c>
  20. Header set X-UA-Compatible "IE=Edge,chrome=1"
  21. # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  22. <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
  23. Header unset X-UA-Compatible
  24. </FilesMatch>
  25. </IfModule>
  26. # ----------------------------------------------------------------------
  27. # Cross-domain AJAX requests
  28. # ----------------------------------------------------------------------
  29. # Serve cross-domain ajax requests, disabled.
  30. # enable-cors.org
  31. # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
  32. # <IfModule mod_headers.c>
  33. # Header set Access-Control-Allow-Origin "*"
  34. # </IfModule>
  35. # ----------------------------------------------------------------------
  36. # Webfont access
  37. # ----------------------------------------------------------------------
  38. # Allow access from all domains for webfonts.
  39. # Alternatively you could only whitelist your
  40. # subdomains like "subdomain.example.com".
  41. <IfModule mod_headers.c>
  42. <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
  43. Header set Access-Control-Allow-Origin "*"
  44. </FilesMatch>
  45. </IfModule>
  46. # ----------------------------------------------------------------------
  47. # Proper MIME type for all files
  48. # ----------------------------------------------------------------------
  49. # JavaScript
  50. # Normalize to standard type (it's sniffed in IE anyways)
  51. # tools.ietf.org/html/rfc4329#section-7.2
  52. AddType application/javascript js
  53. # Audio
  54. AddType audio/ogg oga ogg
  55. AddType audio/mp4 m4a
  56. # Video
  57. AddType video/ogg ogv
  58. AddType video/mp4 mp4 m4v
  59. AddType video/webm webm
  60. # SVG.
  61. # Required for svg webfonts on iPad
  62. # twitter.com/FontSquirrel/status/14855840545
  63. AddType image/svg+xml svg svgz
  64. AddEncoding gzip svgz
  65. # Webfonts
  66. AddType application/vnd.ms-fontobject eot
  67. AddType application/x-font-ttf ttf ttc
  68. AddType font/opentype otf
  69. AddType application/x-font-woff woff
  70. # Assorted types
  71. AddType image/x-icon ico
  72. AddType image/webp webp
  73. AddType text/cache-manifest appcache manifest
  74. AddType text/x-component htc
  75. AddType application/x-chrome-extension crx
  76. AddType application/x-xpinstall xpi
  77. AddType application/octet-stream safariextz
  78. AddType text/x-vcard vcf
  79. # ----------------------------------------------------------------------
  80. # Allow concatenation from within specific js and css files
  81. # ----------------------------------------------------------------------
  82. # e.g. Inside of script.combined.js you could have
  83. # <!--#include file="libs/jquery-1.5.0.min.js" -->
  84. # <!--#include file="plugins/jquery.idletimer.js" -->
  85. # and they would be included into this single file.
  86. # This is not in use in the boilerplate as it stands. You may
  87. # choose to name your files in this way for this advantage or
  88. # concatenate and minify them manually.
  89. # Disabled by default.
  90. #<FilesMatch "\.combined\.js$">
  91. # Options +Includes
  92. # AddOutputFilterByType INCLUDES application/javascript application/json
  93. # SetOutputFilter INCLUDES
  94. #</FilesMatch>
  95. #<FilesMatch "\.combined\.css$">
  96. # Options +Includes
  97. # AddOutputFilterByType INCLUDES text/css
  98. # SetOutputFilter INCLUDES
  99. #</FilesMatch>
  100. # ----------------------------------------------------------------------
  101. # Gzip compression
  102. # ----------------------------------------------------------------------
  103. <IfModule mod_deflate.c>
  104. # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  105. <IfModule mod_setenvif.c>
  106. <IfModule mod_headers.c>
  107. SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  108. RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  109. </IfModule>
  110. </IfModule>
  111. # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
  112. <IfModule filter_module>
  113. FilterDeclare COMPRESS
  114. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
  115. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
  116. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
  117. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
  118. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
  119. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
  120. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
  121. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
  122. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
  123. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
  124. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
  125. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
  126. FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
  127. FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
  128. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
  129. FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
  130. FilterChain COMPRESS
  131. FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
  132. </IfModule>
  133. <IfModule !mod_filter.c>
  134. # Legacy versions of Apache
  135. AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
  136. AddOutputFilterByType DEFLATE application/javascript
  137. AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
  138. AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
  139. AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
  140. </IfModule>
  141. </IfModule>
  142. # ----------------------------------------------------------------------
  143. # Expires headers (for better cache control)
  144. # ----------------------------------------------------------------------
  145. # These are pretty far-future expires headers.
  146. # They assume you control versioning with cachebusting query params like
  147. # <script src="application.js?20100608">
  148. # Additionally, consider that outdated proxies may miscache
  149. # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
  150. # If you don't use filenames to version, lower the CSS and JS to something like
  151. # "access plus 1 week" or so.
  152. <IfModule mod_expires.c>
  153. ExpiresActive on
  154. # Perhaps better to whitelist expires rules? Perhaps.
  155. ExpiresDefault "access plus 1 month"
  156. # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
  157. ExpiresByType text/cache-manifest "access plus 0 seconds"
  158. # Your document html
  159. ExpiresByType text/html "access plus 0 seconds"
  160. # Data
  161. ExpiresByType text/xml "access plus 0 seconds"
  162. ExpiresByType application/xml "access plus 0 seconds"
  163. ExpiresByType application/json "access plus 0 seconds"
  164. # Feed
  165. ExpiresByType application/rss+xml "access plus 1 hour"
  166. ExpiresByType application/atom+xml "access plus 1 hour"
  167. # Favicon (cannot be renamed)
  168. ExpiresByType image/x-icon "access plus 1 week"
  169. # Media: images, video, audio
  170. ExpiresByType image/gif "access plus 1 month"
  171. ExpiresByType image/png "access plus 1 month"
  172. ExpiresByType image/jpg "access plus 1 month"
  173. ExpiresByType image/jpeg "access plus 1 month"
  174. ExpiresByType video/ogg "access plus 1 month"
  175. ExpiresByType audio/ogg "access plus 1 month"
  176. ExpiresByType video/mp4 "access plus 1 month"
  177. ExpiresByType video/webm "access plus 1 month"
  178. # HTC files (css3pie)
  179. ExpiresByType text/x-component "access plus 1 month"
  180. # Webfonts
  181. ExpiresByType application/x-font-ttf "access plus 1 month"
  182. ExpiresByType font/opentype "access plus 1 month"
  183. ExpiresByType application/x-font-woff "access plus 1 month"
  184. ExpiresByType image/svg+xml "access plus 1 month"
  185. ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  186. # CSS and JavaScript
  187. ExpiresByType text/css "access plus 1 year"
  188. ExpiresByType application/javascript "access plus 1 year"
  189. <IfModule mod_headers.c>
  190. Header append Cache-Control "public"
  191. </IfModule>
  192. </IfModule>
  193. # ----------------------------------------------------------------------
  194. # ETag removal
  195. # ----------------------------------------------------------------------
  196. # FileETag None is not enough for every server.
  197. <IfModule mod_headers.c>
  198. Header unset ETag
  199. </IfModule>
  200. # Since we're sending far-future expires, we don't need ETags for
  201. # static content.
  202. # developer.yahoo.com/performance/rules.html#etags
  203. FileETag None
  204. # ----------------------------------------------------------------------
  205. # Stop screen flicker in IE on CSS rollovers
  206. # ----------------------------------------------------------------------
  207. # The following directives stop screen flicker in IE on CSS rollovers - in
  208. # combination with the "ExpiresByType" rules for images (see above). If
  209. # needed, un-comment the following rules.
  210. # BrowserMatch "MSIE" brokenvary=1
  211. # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
  212. # BrowserMatch "Opera" !brokenvary
  213. # SetEnvIf brokenvary 1 force-no-vary
  214. # ----------------------------------------------------------------------
  215. # Cookie setting from iframes
  216. # ----------------------------------------------------------------------
  217. # Allow cookies to be set from iframes (for IE only)
  218. # If needed, uncomment and specify a path or regex in the Location directive
  219. # <IfModule mod_headers.c>
  220. # <Location />
  221. # Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
  222. # </Location>
  223. # </IfModule>
  224. # ----------------------------------------------------------------------
  225. # Start rewrite engine
  226. # ----------------------------------------------------------------------
  227. # Turning on the rewrite engine is necessary for the following rules and features.
  228. # FollowSymLinks must be enabled for this to work.
  229. <IfModule mod_rewrite.c>
  230. Options +FollowSymlinks
  231. RewriteEngine On
  232. </IfModule>
  233. # ----------------------------------------------------------------------
  234. # Suppress or force the "www." at the beginning of URLs
  235. # ----------------------------------------------------------------------
  236. # The same content should never be available under two different URLs - especially not with and
  237. # without "www." at the beginning, since this can cause SEO problems (duplicate content).
  238. # That's why you should choose one of the alternatives and redirect the other one.
  239. # By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier.
  240. # no-www.org/faq.php?q=class_b
  241. # If you rather want to use option 2, just comment out all option 1 lines
  242. # and uncomment option 2.
  243. # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
  244. # ----------------------------------------------------------------------
  245. # Option 1:
  246. # Rewrite "www.example.com -> example.com"
  247. <IfModule mod_rewrite.c>
  248. RewriteCond %{HTTPS} !=on
  249. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  250. RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
  251. </IfModule>
  252. # ----------------------------------------------------------------------
  253. # Option 2:
  254. # To rewrite "example.com -> www.example.com" uncomment the following lines.
  255. # Be aware that the following rule might not be a good idea if you
  256. # use "real" subdomains for certain parts of your website.
  257. # <IfModule mod_rewrite.c>
  258. # RewriteCond %{HTTPS} !=on
  259. # RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
  260. # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  261. # </IfModule>
  262. # ----------------------------------------------------------------------
  263. # Built-in filename-based cache busting
  264. # ----------------------------------------------------------------------
  265. # If you're not using the build script to manage your filename version revving,
  266. # you might want to consider enabling this, which will route requests for
  267. # /css/style.20110203.css to /css/style.css
  268. # To understand why this is important and a better idea than all.css?v1231,
  269. # read: github.com/paulirish/html5-boilerplate/wiki/Version-Control-with-Cachebusting
  270. # Uncomment to enable.
  271. # <IfModule mod_rewrite.c>
  272. # RewriteCond %{REQUEST_FILENAME} !-f
  273. # RewriteCond %{REQUEST_FILENAME} !-d
  274. # RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
  275. # </IfModule>
  276. # ----------------------------------------------------------------------
  277. # Prevent SSL cert warnings
  278. # ----------------------------------------------------------------------
  279. # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
  280. # https://www.example.com when your cert only allows https://secure.example.com
  281. # Uncomment the following lines to use this feature.
  282. # <IfModule mod_rewrite.c>
  283. # RewriteCond %{SERVER_PORT} !^443
  284. # RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L]
  285. # </IfModule>
  286. # ----------------------------------------------------------------------
  287. # Prevent 404 errors for non-existing redirected folders
  288. # ----------------------------------------------------------------------
  289. # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
  290. # e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
  291. Options -MultiViews
  292. # ----------------------------------------------------------------------
  293. # Custom 404 page
  294. # ----------------------------------------------------------------------
  295. # You can add custom pages to handle 500 or 403 pretty easily, if you like.
  296. ErrorDocument 404 /404.html
  297. # ----------------------------------------------------------------------
  298. # UTF-8 encoding
  299. # ----------------------------------------------------------------------
  300. # Use UTF-8 encoding for anything served text/plain or text/html
  301. AddDefaultCharset utf-8
  302. # Force UTF-8 for a number of file formats
  303. AddCharset utf-8 .html .css .js .xml .json .rss .atom
  304. # ----------------------------------------------------------------------
  305. # A little more security
  306. # ----------------------------------------------------------------------
  307. # Do we want to advertise the exact version number of Apache we're running?
  308. # Probably not.
  309. ## This can only be enabled if used in httpd.conf - It will not work in .htaccess
  310. # ServerTokens Prod
  311. # "-Indexes" will have Apache block users from browsing folders without a default document
  312. # Usually you should leave this activated, because you shouldn't allow everybody to surf through
  313. # every folder on your server (which includes rather private places like CMS system folders).
  314. <IfModule mod_autoindex.c>
  315. Options -Indexes
  316. </IfModule>
  317. # Block access to "hidden" directories whose names begin with a period. This
  318. # includes directories used by version control systems such as Subversion or Git.
  319. <IfModule mod_rewrite.c>
  320. RewriteRule "(^|/)\." - [F]
  321. </IfModule>
  322. # If your server is not already configured as such, the following directive
  323. # should be uncommented in order to set PHP's register_globals option to OFF.
  324. # This closes a major security hole that is abused by most XSS (cross-site
  325. # scripting) attacks. For more information: http://php.net/register_globals
  326. #
  327. # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
  328. #
  329. # Your server does not allow PHP directives to be set via .htaccess. In that
  330. # case you must make this change in your php.ini file instead. If you are
  331. # using a commercial web host, contact the administrators for assistance in
  332. # doing this. Not all servers allow local php.ini files, and they should
  333. # include all PHP configurations (not just this one), or you will effectively
  334. # reset everything to PHP defaults. Consult www.php.net for more detailed
  335. # information about setting PHP directives.
  336. # php_flag register_globals Off
  337. # Rename session cookie to something else, than PHPSESSID
  338. # php_value session.name sid
  339. # Do not show you are using PHP
  340. # Note: Move this line to php.ini since it won't work in .htaccess
  341. # php_flag expose_php Off
  342. # Level of log detail - log all errors
  343. # php_value error_reporting -1
  344. # Write errors to log file
  345. # php_flag log_errors On
  346. # Do not display errors in browser (production - Off, development - On)
  347. # php_flag display_errors Off
  348. # Do not display startup errors (production - Off, development - On)
  349. # php_flag display_startup_errors Off
  350. # Format errors in plain text
  351. # Note: Leave this setting 'On' for xdebug's var_dump() output
  352. # php_flag html_errors Off
  353. # Show multiple occurrence of error
  354. # php_flag ignore_repeated_errors Off
  355. # Show same errors from different sources
  356. # php_flag ignore_repeated_source Off
  357. # Size limit for error messages
  358. # php_value log_errors_max_len 1024
  359. # Don't precede error with string (doesn't accept empty string, use whitespace if you need)
  360. # php_value error_prepend_string " "
  361. # Don't prepend to error (doesn't accept empty string, use whitespace if you need)
  362. # php_value error_append_string " "
  363. # Increase cookie security
  364. <IfModule php5_module>
  365. php_value session.cookie_httponly true
  366. </IfModule>