Advertisement
Guest User

htaccess for wordpress

a guest
Dec 9th, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 9.69 KB | None | 0 0
  1. # from html5boilerplate by paul irish
  2. # ----------------------------------------------------------------------
  3. # Better website experience for IE users
  4. # ----------------------------------------------------------------------
  5.  
  6. # Force the latest IE version, in various cases when it may fall back to IE7 mode
  7. #  github.com/rails/rails/commit/123eb25#commitcomment-118920
  8. # Use ChromeFrame if it's installed for a better experience for the poor IE folk
  9.  
  10. <IfModule mod_headers.c>
  11.   Header set X-UA-Compatible "IE=Edge,chrome=1"
  12.   # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  13.   <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
  14.     Header unset X-UA-Compatible
  15.   </FilesMatch>
  16. </IfModule>
  17.  
  18.  
  19. # ----------------------------------------------------------------------
  20. # Cross-domain AJAX requests
  21. # ----------------------------------------------------------------------
  22.  
  23. # Serve cross-domain Ajax requests, disabled by default.
  24. # enable-cors.org
  25. # code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
  26.  
  27.  <IfModule mod_headers.c>
  28.     Header set Access-Control-Allow-Origin "*"
  29.   </IfModule>
  30.  
  31.  
  32. # ----------------------------------------------------------------------
  33. # Proper MIME type for all files
  34. # ----------------------------------------------------------------------
  35.  
  36. # JavaScript
  37. #   Normalize to standard type (it's sniffed in IE anyways)
  38. #   tools.ietf.org/html/rfc4329#section-7.2
  39. AddType application/javascript         js jsonp
  40. AddType application/json               json
  41.  
  42. # Audio
  43. AddType audio/mp4                      m4a f4a f4b
  44. AddType audio/ogg                      oga ogg
  45.  
  46. # Video
  47. AddType video/mp4                      mp4 m4v f4v f4p
  48. AddType video/ogg                      ogv
  49. AddType video/webm                     webm
  50. AddType video/x-flv                    flv
  51.  
  52. # SVG
  53. #   Required for svg webfonts on iPad
  54. #   twitter.com/FontSquirrel/status/14855840545
  55. AddType     image/svg+xml              svg svgz
  56. AddEncoding gzip                       svgz
  57.  
  58. # Webfonts
  59. AddType application/vnd.ms-fontobject  eot
  60. AddType application/x-font-ttf         ttf ttc
  61. AddType application/x-font-woff        woff
  62. AddType font/opentype                  otf
  63.  
  64. # Assorted types
  65. AddType application/octet-stream            safariextz
  66. AddType application/x-chrome-extension      crx
  67. AddType application/x-opera-extension       oex
  68. AddType application/x-shockwave-flash       swf
  69. AddType application/x-web-app-manifest+json webapp
  70. AddType application/x-xpinstall             xpi
  71. AddType application/xml                     rss atom xml rdf
  72. AddType image/webp                          webp
  73. AddType image/x-icon                        ico
  74. AddType text/cache-manifest                 appcache manifest
  75. AddType text/vtt                            vtt
  76. AddType text/x-component                    htc
  77. AddType text/x-vcard                        vcf
  78.  
  79.  
  80. # ----------------------------------------------------------------------
  81. # Gzip compression
  82. # ----------------------------------------------------------------------
  83.  
  84. <IfModule mod_deflate.c>
  85.  
  86.   # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  87.   <IfModule mod_setenvif.c>
  88.     <IfModule mod_headers.c>
  89.       SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  90.       RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  91.     </IfModule>
  92.   </IfModule>
  93.  
  94.   # Compress all output labeled with one of the following MIME-types
  95.   # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
  96.   # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines as
  97.   # `AddOutputFilterByType` is still in the core directives)
  98.   <IfModule mod_filter.c>
  99.     AddOutputFilterByType DEFLATE application/atom+xml \
  100.                                   application/javascript \
  101.                                   application/json \
  102.                                   application/rss+xml \
  103.                                   application/vnd.ms-fontobject \
  104.                                   application/x-font-ttf \
  105.                                   application/xhtml+xml \
  106.                                   application/xml \
  107.                                   font/opentype \
  108.                                   image/svg+xml \
  109.                                   image/x-icon \
  110.                                   text/css \
  111.                                   text/html \
  112.                                   text/plain \
  113.                                   text/x-component \
  114.                                   text/xml
  115.   </IfModule>
  116.  
  117. </IfModule>
  118.  
  119.  
  120. # ----------------------------------------------------------------------
  121. # Expires headers (for better cache control)
  122. # ----------------------------------------------------------------------
  123.  
  124. # These are pretty far-future expires headers.
  125. # They assume you control versioning with filename-based cache busting
  126. # Additionally, consider that outdated proxies may miscache
  127. #   www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
  128.  
  129. # If you don't use filenames to version, lower the CSS and JS to something like
  130. # "access plus 1 week".
  131.  
  132. <IfModule mod_expires.c>
  133.   ExpiresActive on
  134.  
  135. # Perhaps better to whitelist expires rules? Perhaps.
  136.   ExpiresDefault                          "access plus 1 month"
  137.  
  138. # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
  139.   ExpiresByType text/cache-manifest       "access plus 0 seconds"
  140.  
  141. # Your document html
  142.   ExpiresByType text/html                 "access plus 0 seconds"
  143.  
  144. # Data
  145.   ExpiresByType application/json          "access plus 0 seconds"
  146.   ExpiresByType application/xml           "access plus 0 seconds"
  147.   ExpiresByType text/xml                  "access plus 0 seconds"
  148.  
  149. # Feed
  150.   ExpiresByType application/atom+xml      "access plus 1 hour"
  151.   ExpiresByType application/rss+xml       "access plus 1 hour"
  152.  
  153. # Favicon (cannot be renamed)
  154.   ExpiresByType image/x-icon              "access plus 1 week"
  155.  
  156. # Media: images, video, audio
  157.   ExpiresByType audio/ogg                 "access plus 1 month"
  158.   ExpiresByType image/gif                 "access plus 1 month"
  159.   ExpiresByType image/jpeg                "access plus 1 month"
  160.   ExpiresByType image/png                 "access plus 1 month"
  161.   ExpiresByType video/mp4                 "access plus 1 month"
  162.   ExpiresByType video/ogg                 "access plus 1 month"
  163.   ExpiresByType video/webm                "access plus 1 month"
  164.  
  165. # HTC files  (css3pie)
  166.   ExpiresByType text/x-component          "access plus 1 month"
  167.  
  168. # Webfonts
  169.   ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  170.   ExpiresByType application/x-font-ttf    "access plus 1 month"
  171.   ExpiresByType application/x-font-woff   "access plus 1 month"
  172.   ExpiresByType font/opentype             "access plus 1 month"
  173.   ExpiresByType image/svg+xml             "access plus 1 month"
  174.  
  175. # CSS and JavaScript
  176.   ExpiresByType application/javascript    "access plus 1 year"
  177.   ExpiresByType text/css                  "access plus 1 year"
  178.  
  179. </IfModule>
  180.  
  181.  
  182. # ----------------------------------------------------------------------
  183. # Prevent mobile network providers from modifying your site
  184. # ----------------------------------------------------------------------
  185.  
  186. # The following header prevents modification of your code over 3G on some
  187. # European providers.
  188. # This is the official 'bypass' suggested by O2 in the UK.
  189.  
  190.  <IfModule mod_headers.c>
  191.  Header set Cache-Control "no-transform"
  192.  </IfModule>
  193.  
  194.  
  195. # ----------------------------------------------------------------------
  196. # ETag removal
  197. # ----------------------------------------------------------------------
  198.  
  199. # FileETag None is not enough for every server.
  200. <IfModule mod_headers.c>
  201.   Header unset ETag
  202. </IfModule>
  203.  
  204. # Since we're sending far-future expires, we don't need ETags for
  205. # static content.
  206. #   developer.yahoo.com/performance/rules.html#etags
  207. FileETag None
  208.  
  209.  
  210.  
  211.  
  212. # ----------------------------------------------------------------------
  213. # Set Keep-Alive Header
  214. # ----------------------------------------------------------------------
  215.  
  216. # Keep-Alive allows the server to send multiple requests through one
  217. # TCP-connection. Be aware of possible disadvantages of this setting. Turn on
  218. # if you serve a lot of static content.
  219.  
  220. <IfModule mod_headers.c>
  221.    Header set Connection Keep-Alive
  222.  </IfModule>
  223.  
  224.  
  225.  
  226.  
  227.  
  228. # ----------------------------------------------------------------------
  229. # UTF-8 encoding
  230. # ----------------------------------------------------------------------
  231.  
  232. # Use UTF-8 encoding for anything served text/plain or text/html
  233. AddDefaultCharset utf-8
  234.  
  235. # Force UTF-8 for a number of file formats
  236. AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
  237.  
  238.  
  239. # ----------------------------------------------------------------------
  240. # A little more security
  241. # ----------------------------------------------------------------------
  242.  
  243. # To avoid displaying the exact version number of Apache being used, add the
  244. # following to httpd.conf (it will not work in .htaccess):
  245. # ServerTokens Prod
  246.  
  247. # "-Indexes" will have Apache block users from browsing folders without a
  248. # default document Usually you should leave this activated, because you
  249. # shouldn't allow everybody to surf through every folder on your server (which
  250. # includes rather private places like CMS system folders).
  251. <IfModule mod_autoindex.c>
  252.   Options -Indexes
  253. </IfModule>
  254.  
  255.  
  256. #paste wordpress .htaccess rules originally found in your .htaccess file below this line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement