Initial Commmit , imort from html5boilerplate
[YAH5BP.git] / .htaccess
blobc5162c5d8b275ce36c5f45acbd105756cfa99c6d
1 # Apache configuration file
2 # httpd.apache.org/docs/2.2/mod/quickreference.html
4 # Note .htaccess files are an overhead, this logic should be in your Apache config if possible
5 # httpd.apache.org/docs/2.2/howto/htaccess.html
7 # Techniques in here adapted from all over, including:
8 #   Kroc Camen: camendesign.com/.htaccess
9 #   perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
10 #   Sample .htaccess file of CMS MODx: modxcms.com
13 ###
14 ### If you run a webserver other than apache, consider:
15 ### github.com/paulirish/html5-boilerplate-server-configs
16 ###
20 # ----------------------------------------------------------------------
21 # Better website experience for IE users
22 # ----------------------------------------------------------------------
24 # Force the latest IE version, in various cases when it may fall back to IE7 mode
25 #  github.com/rails/rails/commit/123eb25#commitcomment-118920
26 # Use ChromeFrame if it's installed for a better experience for the poor IE folk
28 <IfModule mod_setenvif.c>
29   <IfModule mod_headers.c>
30     BrowserMatch MSIE ie
31     Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
32   </IfModule>
33 </IfModule>
35 <IfModule mod_headers.c>
36 # Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
37 #   We need to inform proxies that content changes based on UA
38   Header append Vary User-Agent
39 # Cache control is set only if mod_headers is enabled, so that's unncessary to declare
40 </IfModule>
43 # ----------------------------------------------------------------------
44 # Cross-domain AJAX requests
45 # ----------------------------------------------------------------------
47 # Serve cross-domain ajax requests, disabled.   
48 # enable-cors.org
49 # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
51 #  <IfModule mod_headers.c>
52 #    Header set Access-Control-Allow-Origin "*"
53 #  </IfModule>
57 # ----------------------------------------------------------------------
58 # Webfont access
59 # ----------------------------------------------------------------------
61 # allow access from all domains for webfonts
62 # alternatively you could only whitelist
63 #   your subdomains like "sub.domain.com"
65 <FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
66   <IfModule mod_headers.c>
67     Header set Access-Control-Allow-Origin "*"
68   </IfModule>
69 </FilesMatch>
73 # ----------------------------------------------------------------------
74 # Proper MIME type for all files
75 # ----------------------------------------------------------------------
77 # audio
78 AddType audio/ogg                      oga ogg
80 # video
81 AddType video/ogg                      ogv
82 AddType video/mp4                      mp4
83 AddType video/webm                     webm
85 # Proper svg serving. Required for svg webfonts on iPad
86 #   twitter.com/FontSquirrel/status/14855840545
87 AddType     image/svg+xml              svg svgz 
88 AddEncoding gzip                       svgz
89                                        
90 # webfonts                             
91 AddType application/vnd.ms-fontobject  eot
92 AddType font/truetype                  ttf
93 AddType font/opentype                  otf
94 AddType application/x-font-woff        woff
96 # assorted types                                      
97 AddType image/x-icon                   ico
98 AddType image/webp                     webp
99 AddType text/cache-manifest            appcache manifest
100 AddType text/x-component               htc
101 AddType application/x-chrome-extension crx
102 AddType application/x-xpinstall        xpi
103 AddType application/octet-stream       safariextz
104 AddType text/x-vcard                   vcf
108 # ----------------------------------------------------------------------
109 # Allow concatenation from within specific js and css files 
110 # ----------------------------------------------------------------------
112 # e.g. Inside of script.combined.js you could have
113 #   <!--#include file="libs/jquery-1.5.0.min.js" -->
114 #   <!--#include file="plugins/jquery.idletimer.js" -->
115 # and they would be included into this single file
117 # this is not in use in the boilerplate as it stands. you may
118 #   choose to name your files in this way for this advantage
119 #   or concatenate and minify them manually.
120 # Disabled by default.
122 # <FilesMatch "\.combined\.(js|css)$">
123 #         Options +Includes
124 #         SetOutputFilter INCLUDES
125 # </FilesMatch>
129 # ----------------------------------------------------------------------
130 # gzip compression
131 # ----------------------------------------------------------------------
133 <IfModule mod_deflate.c>
136 # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
137 <IfModule mod_setenvif.c>
138   <IfModule mod_headers.c>
139     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
140     RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
141   </IfModule>
142 </IfModule>
143 # html, txt, css, js, json, xml, htc:
144 <IfModule filter_module>
145   FilterDeclare   COMPRESS
146   FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
147   FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
148   FilterChain     COMPRESS
149   FilterProtocol  COMPRESS  change=yes;byteranges=no
150 </IfModule>
152 <IfModule !mod_filter.c>
153   # Legacy versions of Apache
154   AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
155   AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript 
156   AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
157 </IfModule>
159 # webfonts and svg:
160   <FilesMatch "\.(ttf|otf|eot|svg)$" >
161     SetOutputFilter DEFLATE
162   </FilesMatch>
163 </IfModule>
167 # ----------------------------------------------------------------------
168 # Expires headers (for better cache control)
169 # ----------------------------------------------------------------------
171 # these are pretty far-future expires headers
172 # they assume you control versioning with cachebusting query params like
173 #   <script src="application.js?20100608">
174 # additionally, consider that outdated proxies may miscache 
175 #   www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
177 # if you don't use filenames to version, lower the css and js to something like
178 #   "access plus 1 week" or so
180 <IfModule mod_expires.c>
181   ExpiresActive on
183 # Perhaps better to whitelist expires rules? Perhaps.
184   ExpiresDefault                          "access plus 1 month"
186 # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
187   ExpiresByType text/cache-manifest       "access plus 0 seconds"
189 # your document html 
190   ExpiresByType text/html                 "access plus 0 seconds"
191   
192 # data
193   ExpiresByType text/xml                  "access plus 0 seconds"
194   ExpiresByType application/xml           "access plus 0 seconds"
195   ExpiresByType application/json          "access plus 0 seconds"
197 # rss feed
198   ExpiresByType application/rss+xml       "access plus 1 hour"
200 # favicon (cannot be renamed)
201   ExpiresByType image/x-icon              "access plus 1 week" 
203 # media: images, video, audio
204   ExpiresByType image/gif                 "access plus 1 month"
205   ExpiresByType image/png                 "access plus 1 month"
206   ExpiresByType image/jpg                 "access plus 1 month"
207   ExpiresByType image/jpeg                "access plus 1 month"
208   ExpiresByType video/ogg                 "access plus 1 month"
209   ExpiresByType audio/ogg                 "access plus 1 month"
210   ExpiresByType video/mp4                 "access plus 1 month"
211   ExpiresByType video/webm                "access plus 1 month"
212   
213 # htc files  (css3pie)
214   ExpiresByType text/x-component          "access plus 1 month"
215   
216 # webfonts
217   ExpiresByType font/truetype             "access plus 1 month"
218   ExpiresByType font/opentype             "access plus 1 month"
219   ExpiresByType application/x-font-woff   "access plus 1 month"
220   ExpiresByType image/svg+xml             "access plus 1 month"
221   ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
222     
223 # css and javascript
224   ExpiresByType text/css                  "access plus 2 months"
225   ExpiresByType application/javascript    "access plus 2 months"
226   ExpiresByType text/javascript           "access plus 2 months"
227   
228   <IfModule mod_headers.c>
229     Header append Cache-Control "public"
230   </IfModule>
231   
232 </IfModule>
236 # ----------------------------------------------------------------------
237 # ETag removal
238 # ----------------------------------------------------------------------
240 # Since we're sending far-future expires, we don't need ETags for
241 # static content.
242 #   developer.yahoo.com/performance/rules.html#etags
243 FileETag None
247 # ----------------------------------------------------------------------
248 # Stop screen flicker in IE on CSS rollovers
249 # ----------------------------------------------------------------------
251 # The following directives stop screen flicker in IE on CSS rollovers - in
252 # combination with the "ExpiresByType" rules for images (see above). If
253 # needed, un-comment the following rules.
255 # BrowserMatch "MSIE" brokenvary=1
256 # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
257 # BrowserMatch "Opera" !brokenvary
258 # SetEnvIf brokenvary 1 force-no-vary
262 # ----------------------------------------------------------------------
263 # Cookie setting from iframes
264 # ----------------------------------------------------------------------
266 # Allow cookies to be set from iframes (for IE only)
267 # If needed, uncomment and specify a path or regex in the Location directive
269 # <IfModule mod_headers.c>
270 #   <Location />
271 #     Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
272 #   </Location>
273 # </IfModule>
277 # ----------------------------------------------------------------------
278 # Start rewrite engine
279 # ----------------------------------------------------------------------
281 # Turning on the rewrite engine is necessary for the following rules and features.
283 <IfModule mod_rewrite.c>
284   RewriteEngine On
285 </IfModule>
289 # ----------------------------------------------------------------------
290 # Suppress or force the "www." at the beginning of URLs
291 # ----------------------------------------------------------------------
293 # The same content should never be available under two different URLs - especially not with and
294 # without "www." at the beginning, since this can cause SEO problems (duplicate content).
295 # That's why you should choose one of the alternatives and redirect the other one.
297 # By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier.
298 # no-www.org/faq.php?q=class_b
300 # If you rather want to use option 2, just comment out all option 1 lines
301 # and uncomment option 2.
302 # IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
304 # ----------------------------------------------------------------------
306 # Option 1:
307 # Rewrite "www.domain.com -> domain.com" 
309 <IfModule mod_rewrite.c>
310   RewriteCond %{HTTPS} !=on
311   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
312   RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
313 </IfModule>
315 # ----------------------------------------------------------------------
317 # Option 2:
318 # To rewrite "domain.com -> www.domain.com" uncomment the following lines.
319 # Be aware that the following rule might not be a good idea if you
320 # use "real" subdomains for certain parts of your website.
322 # <IfModule mod_rewrite.c>
323 #   RewriteCond %{HTTPS} !=on
324 #   RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
325 #   RewriteCond %{HTTP_HOST} (.+)$ [NC]
326 #   RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
327 # </IfModule>
331 # ----------------------------------------------------------------------
332 # Add/remove trailing slash to (non-file) URLs
333 # ----------------------------------------------------------------------
335 # Google treats URLs with and without trailing slashes separately.
336 # Forcing a trailing slash is usually preferred, but all that's really
337 # important is that one correctly redirects to the other.
339 # By default option 1 (force trailing slash) is activated.
340 # http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html
341 # http://www.alistapart.com/articles/slashforward/
342 # http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#url Trailing Slash Problem
344 # ----------------------------------------------------------------------
346 # Option 1:
347 # Rewrite "domain.com/foo -> domain.com/foo/"
349 <IfModule mod_rewrite.c>
350   RewriteCond %{REQUEST_FILENAME} !-f
351   RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
352   RewriteRule ^(.*)$ /$1/ [R=301,L]
353 </IfModule>
355 # ----------------------------------------------------------------------
357 # Option 2:
358 # Rewrite "domain.com/foo/ -> domain.com/foo"
360 #<IfModule mod_rewrite.c>
361 #  RewriteRule ^(.*)/$ /$1 [R=301,L]
362 #</IfModule>
366 # ----------------------------------------------------------------------
367 # Built-in filename-based cache busting
368 # ----------------------------------------------------------------------
370 # If you're not using the build script to manage your filename version revving,
371 # you might want to consider enabling this, which will route requests for
372 # /css/style.20110203.css to /css/style.css
374 # To understand why this is important and a better idea than all.css?v1231,
375 # read: github.com/paulirish/html5-boilerplate/wiki/Version-Control-with-Cachebusting
377 # Uncomment to enable.
378 # <IfModule mod_rewrite.c>
379 #   RewriteCond %{REQUEST_FILENAME} !-f
380 #   RewriteCond %{REQUEST_FILENAME} !-d
381 #   RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
382 # </IfModule>
385         
386 # ----------------------------------------------------------------------
387 # Prevent SSL cert warnings
388 # ----------------------------------------------------------------------
390 # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent 
391 # https://www.domain.com when your cert only allows https://secure.domain.com
392 # Uncomment the following lines to use this feature.
394 # <IfModule mod_rewrite.c>
395 #   RewriteCond %{SERVER_PORT} !^443
396 #   RewriteRule (.*) https://example-domain-please-change-me.com/$1 [R=301,L]
397 # </IfModule>
401 # ----------------------------------------------------------------------
402 # Prevent 404 errors for non-existing redirected folders
403 # ----------------------------------------------------------------------
405 # without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist 
406 #   e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
408 Options -MultiViews 
412 # ----------------------------------------------------------------------
413 # custom 404 page
414 # ----------------------------------------------------------------------
416 # You can add custom pages to handle 500 or 403 pretty easily, if you like.
417 ErrorDocument 404 /404.html
421 # ----------------------------------------------------------------------
422 # UTF-8 encoding
423 # ----------------------------------------------------------------------
425 # use utf-8 encoding for anything served text/plain or text/html
426 AddDefaultCharset utf-8
428 # force utf-8 for a number of file formats
429 AddCharset utf-8 .html .css .js .xml .json .rss
433 # ----------------------------------------------------------------------
434 # A little more security
435 # ----------------------------------------------------------------------
438 # Do we want to advertise the exact version number of Apache we're running?
439 # Probably not.
440 ## This can only be enabled if used in httpd.conf - It will not work in .htaccess
441 # ServerTokens Prod
444 # "-Indexes" will have Apache block users from browsing folders without a default document
445 # Usually you should leave this activated, because you shouldn't allow everybody to surf through
446 # every folder on your server (which includes rather private places like CMS system folders).
447 Options -Indexes
450 # Block access to "hidden" directories whose names begin with a period. This
451 # includes directories used by version control systems such as Subversion or Git.
452 <IfModule mod_rewrite.c>
453   RewriteRule "(^|/)\." - [F]
454 </IfModule>
457 # If your server is not already configured as such, the following directive
458 # should be uncommented in order to set PHP's register_globals option to OFF.
459 # This closes a major security hole that is abused by most XSS (cross-site
460 # scripting) attacks. For more information: http://php.net/register_globals
462 # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
464 # Your server does not allow PHP directives to be set via .htaccess. In that
465 # case you must make this change in your php.ini file instead. If you are
466 # using a commercial web host, contact the administrators for assistance in
467 # doing this. Not all servers allow local php.ini files, and they should
468 # include all PHP configurations (not just this one), or you will effectively
469 # reset everything to PHP defaults. Consult www.php.net for more detailed
470 # information about setting PHP directives.
472 # php_flag register_globals Off
475 # Increase cookie security
476 <IfModule php5_module>
477 php_value session.cookie_httponly true
478 </IfModule>