.htaccess 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <IfModule mod_setenvif.c>
  2. <IfModule mod_headers.c>
  3. BrowserMatch MSIE ie
  4. Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
  5. </IfModule>
  6. </IfModule>
  7. <IfModule mod_headers.c>
  8. # Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
  9. # We need to inform proxies that content changes based on UA
  10. Header append Vary User-Agent
  11. # Cache control is set only if mod_headers is enabled, so that's unncessary to declare
  12. </IfModule>
  13. # ----------------------------------------------------------------------
  14. # Webfont access
  15. # ----------------------------------------------------------------------
  16. # allow access from all domains for webfonts
  17. # alternatively you could only whitelist
  18. # your subdomains like "sub.domain.com"
  19. <FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
  20. <IfModule mod_headers.c>
  21. Header set Access-Control-Allow-Origin "*"
  22. </IfModule>
  23. </FilesMatch>
  24. # ----------------------------------------------------------------------
  25. # Proper MIME type for all files
  26. # ----------------------------------------------------------------------
  27. # audio
  28. AddType audio/ogg oga ogg
  29. # video
  30. AddType video/ogg ogv
  31. AddType video/mp4 mp4
  32. AddType video/webm webm
  33. # Proper svg serving. Required for svg webfonts on iPad
  34. # twitter.com/FontSquirrel/status/14855840545
  35. AddType image/svg+xml svg svgz
  36. AddEncoding gzip svgz
  37. # webfonts
  38. AddType application/vnd.ms-fontobject eot
  39. AddType font/truetype ttf
  40. AddType font/opentype otf
  41. AddType application/x-font-woff woff
  42. # assorted types
  43. AddType image/x-icon ico
  44. AddType image/webp webp
  45. AddType text/cache-manifest appcache manifest
  46. AddType text/x-component htc
  47. AddType application/x-chrome-extension crx
  48. AddType application/x-xpinstall xpi
  49. AddType application/octet-stream safariextz
  50. # ----------------------------------------------------------------------
  51. # gzip compression
  52. # ----------------------------------------------------------------------
  53. <IfModule mod_deflate.c>
  54. # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  55. <IfModule mod_setenvif.c>
  56. <IfModule mod_headers.c>
  57. 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
  58. RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  59. </IfModule>
  60. </IfModule>
  61. # html, txt, css, js, json, xml, htc:
  62. <IfModule filter_module>
  63. FilterDeclare COMPRESS
  64. FilterProvider COMPRESS DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
  65. FilterProvider COMPRESS DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
  66. FilterChain COMPRESS
  67. FilterProtocol COMPRESS change=yes;byteranges=no
  68. </IfModule>
  69. <IfModule !mod_filter.c>
  70. # Legacy versions of Apache
  71. AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
  72. AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
  73. AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
  74. </IfModule>
  75. # webfonts and svg:
  76. <FilesMatch "\.(ttf|otf|eot|svg)$" >
  77. SetOutputFilter DEFLATE
  78. </FilesMatch>
  79. </IfModule>
  80. ## # ----------------------------------------------------------------------
  81. ## # Expires headers (for better cache control)
  82. ## # ----------------------------------------------------------------------
  83. ##
  84. ## # these are pretty far-future expires headers
  85. ## # they assume you control versioning with cachebusting query params like
  86. ## # <script src="application.js?20100608">
  87. ## # additionally, consider that outdated proxies may miscache
  88. ## # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
  89. ##
  90. ## # if you don't use filenames to version, lower the css and js to something like
  91. ## # "access plus 1 week" or so
  92. ##
  93. ## <IfModule mod_expires.c>
  94. ## ExpiresActive on
  95. ##
  96. ## # Perhaps better to whitelist expires rules? Perhaps.
  97. ## ExpiresDefault "access plus 1 month"
  98. ##
  99. ## # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
  100. ## ExpiresByType text/cache-manifest "access plus 0 seconds"
  101. ##
  102. ## # your document html
  103. ## ExpiresByType text/html "access plus 0 seconds"
  104. ##
  105. ## # data
  106. ## ExpiresByType text/xml "access plus 0 seconds"
  107. ## ExpiresByType application/xml "access plus 0 seconds"
  108. ## ExpiresByType application/json "access plus 0 seconds"
  109. ##
  110. ## # rss feed
  111. ## ExpiresByType application/rss+xml "access plus 1 hour"
  112. ##
  113. ## # favicon (cannot be renamed)
  114. ## ExpiresByType image/x-icon "access plus 1 week"
  115. ##
  116. ## # media: images, video, audio
  117. ## ExpiresByType image/gif "access plus 1 month"
  118. ## ExpiresByType image/png "access plus 1 month"
  119. ## ExpiresByType image/jpg "access plus 1 month"
  120. ## ExpiresByType image/jpeg "access plus 1 month"
  121. ## ExpiresByType video/ogg "access plus 1 month"
  122. ## ExpiresByType audio/ogg "access plus 1 month"
  123. ## ExpiresByType video/mp4 "access plus 1 month"
  124. ## ExpiresByType video/webm "access plus 1 month"
  125. ##
  126. ## # htc files (css3pie)
  127. ## ExpiresByType text/x-component "access plus 1 month"
  128. ##
  129. ## # webfonts
  130. ## ExpiresByType font/truetype "access plus 1 month"
  131. ## ExpiresByType font/opentype "access plus 1 month"
  132. ## ExpiresByType application/x-font-woff "access plus 1 month"
  133. ## ExpiresByType image/svg+xml "access plus 1 month"
  134. ## ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  135. ##
  136. ## # css and javascript
  137. ## ExpiresByType text/css "access plus 2 months"
  138. ## ExpiresByType application/javascript "access plus 2 months"
  139. ## ExpiresByType text/javascript "access plus 2 months"
  140. ##
  141. ## <IfModule mod_headers.c>
  142. ## Header append Cache-Control "public"
  143. ## </IfModule>
  144. ##
  145. ## </IfModule>
  146. # ----------------------------------------------------------------------
  147. # ETag removal
  148. # ----------------------------------------------------------------------
  149. # Since we're sending far-future expires, we don't need ETags for
  150. # static content.
  151. # developer.yahoo.com/performance/rules.html#etags
  152. FileETag None
  153. # ----------------------------------------------------------------------
  154. # Start rewrite engine
  155. # ----------------------------------------------------------------------
  156. <IfModule mod_rewrite.c>
  157. RewriteEngine On
  158. </IfModule>
  159. # ----------------------------------------------------------------------
  160. # Suppress or force the "www." at the beginning of URLs
  161. # ----------------------------------------------------------------------
  162. # The same content should never be available under two different URLs - especially not with and
  163. # without "www." at the beginning, since this can cause SEO problems (duplicate content).
  164. # That's why you should choose one of the alternatives and redirect the other one.
  165. # By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier.
  166. # no-www.org/faq.php?q=class_b
  167. # If you rather want to use option 2, just comment out all option 1 lines
  168. # and uncomment option 2.
  169. # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
  170. # ----------------------------------------------------------------------
  171. # Option 1:
  172. # Rewrite "www.domain.com -> domain.com"
  173. <IfModule mod_rewrite.c>
  174. RewriteCond %{HTTPS} !=on
  175. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  176. RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  177. </IfModule>
  178. # ----------------------------------------------------------------------
  179. # Symfony front controller
  180. # ----------------------------------------------------------------------
  181. <IfModule mod_rewrite.c>
  182. RewriteCond %{REQUEST_FILENAME} !-f
  183. RewriteRule ^(.*)$ app.php [QSA,L]
  184. </IfModule>
  185. # ----------------------------------------------------------------------
  186. # Built-in filename-based cache busting
  187. # ----------------------------------------------------------------------
  188. # If you're not using the build script to manage your filename version revving,
  189. # you might want to consider enabling this, which will route requests for
  190. # /css/all.20110203.css to /res/all.css
  191. # To understand why this is important and a better idea than all.css?v1231,
  192. # read: github.com/paulirish/html5-boilerplate/wiki/Version-Control-with-Cachebusting
  193. # Uncomment to enable.
  194. # <IfModule mod_rewrite.c>
  195. # RewriteCond %{REQUEST_FILENAME} !-f
  196. # RewriteCond %{REQUEST_FILENAME} !-d
  197. # RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
  198. # </IfModule>
  199. # ----------------------------------------------------------------------
  200. # Prevent SSL cert warnings
  201. # ----------------------------------------------------------------------
  202. # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
  203. # https://www.domain.com when your cert only allows https://secure.domain.com
  204. # Uncomment the following lines to use this feature.
  205. # <IfModule mod_rewrite.c>
  206. # RewriteCond %{SERVER_PORT} !^443
  207. # RewriteRule (.*) https://example-domain-please-change-me.com/$1 [R=301,L]
  208. # </IfModule>
  209. # ----------------------------------------------------------------------
  210. # Prevent 404 errors for non-existing redirected folders
  211. # ----------------------------------------------------------------------
  212. # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
  213. # e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
  214. Options -MultiViews
  215. # ----------------------------------------------------------------------
  216. # UTF-8 encoding
  217. # ----------------------------------------------------------------------
  218. # use utf-8 encoding for anything served text/plain or text/html
  219. AddDefaultCharset utf-8
  220. # force utf-8 for a number of file formats
  221. AddCharset utf-8 .html .css .js .xml .json .rss