You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

540 lines
20 KiB

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