|
| 1 | +# ---------------------------------------------------------------------- |
| 2 | +# Better website experience for IE users |
| 3 | +# ---------------------------------------------------------------------- |
| 4 | + |
| 5 | +# Force the latest IE version, in various cases when it may fall back to IE7 mode |
| 6 | +# github.com/rails/rails/commit/123eb25#commitcomment-118920 |
| 7 | +# Use ChromeFrame if it's installed for a better experience for the poor IE folk |
| 8 | + |
| 9 | +<IfModule mod_headers.c> |
| 10 | + Header set X-UA-Compatible "IE=Edge,chrome=1" |
| 11 | + # mod_headers can't match by content-type, but we don't want to send this header on *everything*... |
| 12 | + <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|woff2|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" > |
| 13 | + Header unset X-UA-Compatible |
| 14 | + </FilesMatch> |
| 15 | +</IfModule> |
| 16 | + |
| 17 | +# ---------------------------------------------------------------------- |
| 18 | +# Proper MIME type for all files |
| 19 | +# ---------------------------------------------------------------------- |
| 20 | + |
| 21 | +# JavaScript |
| 22 | +# Normalize to standard type (it's sniffed in IE anyways) |
| 23 | +# tools.ietf.org/html/rfc4329#section-7.2 |
| 24 | +AddType application/javascript js jsonp |
| 25 | +AddType application/json json |
| 26 | + |
| 27 | +# Audio |
| 28 | +AddType audio/ogg oga ogg |
| 29 | +AddType audio/mp4 m4a f4a f4b |
| 30 | + |
| 31 | +# Video |
| 32 | +AddType video/ogg ogv |
| 33 | +AddType video/mp4 mp4 m4v f4v f4p |
| 34 | +AddType video/webm webm |
| 35 | +AddType video/x-flv flv |
| 36 | + |
| 37 | +# SVG |
| 38 | +# Required for svg webfonts on iPad |
| 39 | +# twitter.com/FontSquirrel/status/14855840545 |
| 40 | +AddType image/svg+xml svg svgz |
| 41 | +AddEncoding gzip svgz |
| 42 | + |
| 43 | +# Webfonts |
| 44 | +AddType application/vnd.ms-fontobject eot |
| 45 | +AddType application/x-font-ttf ttf ttc |
| 46 | +AddType font/opentype otf |
| 47 | +AddType application/x-font-woff woff |
| 48 | +AddType application/font-woff2 woff2 |
| 49 | + |
| 50 | +# Assorted types |
| 51 | +AddType image/x-icon ico |
| 52 | +AddType image/webp webp |
| 53 | +AddType text/cache-manifest appcache manifest |
| 54 | +AddType text/x-component htc |
| 55 | +AddType application/xml rss atom xml rdf |
| 56 | +AddType application/x-chrome-extension crx |
| 57 | +AddType application/x-opera-extension oex |
| 58 | +AddType application/x-xpinstall xpi |
| 59 | +AddType application/octet-stream safariextz |
| 60 | +AddType application/x-web-app-manifest+json webapp |
| 61 | +AddType text/x-vcard vcf |
| 62 | +AddType application/x-shockwave-flash swf |
| 63 | +AddType text/vtt vtt |
| 64 | + |
| 65 | + |
| 66 | +# ---------------------------------------------------------------------- |
| 67 | +# Gzip compression |
| 68 | +# ---------------------------------------------------------------------- |
| 69 | + |
| 70 | +<IfModule mod_deflate.c> |
| 71 | + # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ |
| 72 | + <IfModule mod_setenvif.c> |
| 73 | + <IfModule mod_headers.c> |
| 74 | + SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding |
| 75 | + RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding |
| 76 | + </IfModule> |
| 77 | + </IfModule> |
| 78 | + |
| 79 | + # Compress all output labeled with one of the following MIME-types |
| 80 | + <IfModule mod_filter.c> |
| 81 | + AddOutputFilterByType DEFLATE application/atom+xml \ |
| 82 | + application/javascript \ |
| 83 | + application/json \ |
| 84 | + application/rss+xml \ |
| 85 | + application/vnd.ms-fontobject \ |
| 86 | + application/x-font-ttf \ |
| 87 | + application/xhtml+xml \ |
| 88 | + application/xml \ |
| 89 | + font/opentype \ |
| 90 | + image/svg+xml \ |
| 91 | + image/x-icon \ |
| 92 | + text/css \ |
| 93 | + text/html \ |
| 94 | + text/plain \ |
| 95 | + text/x-component \ |
| 96 | + text/xml |
| 97 | + </IfModule> |
| 98 | +</IfModule> |
| 99 | + |
| 100 | +# ---------------------------------------------------------------------- |
| 101 | +# Start rewrite engine |
| 102 | +# ---------------------------------------------------------------------- |
| 103 | + |
| 104 | +# Turning on the rewrite engine is necessary for the following rules and |
| 105 | +# features. FollowSymLinks must be enabled for this to work. |
| 106 | + |
| 107 | +# Some cloud hosting services require RewriteBase to be set: goo.gl/HOcPN |
| 108 | +# If using the h5bp in a subdirectory, use `RewriteBase /foo` instead where |
| 109 | +# 'foo' is your directory. |
| 110 | + |
| 111 | +# If your web host doesn't allow the FollowSymlinks option, you may need to |
| 112 | +# comment it out and use `Options +SymLinksOfOwnerMatch`, but be aware of the |
| 113 | +# performance impact: http://goo.gl/Mluzd |
| 114 | + |
| 115 | +<IfModule mod_rewrite.c> |
| 116 | + <Directory "${HOME}"> |
| 117 | + |
| 118 | + Options Indexes FollowSymLinks |
| 119 | + AllowOverride All |
| 120 | + Order Allow,Deny |
| 121 | + Allow from All |
| 122 | + |
| 123 | + RewriteEngine On |
| 124 | + RewriteBase / |
| 125 | + |
| 126 | + # Redirects for "latest" version |
| 127 | + RewriteRule ^origin-m4/?$ /latest/ [R=301] |
| 128 | + |
| 129 | + # Welcome page redirects |
| 130 | + RewriteRule ^(latest|[0-9.]+)/?$ /$1/welcome/index.html [L,R=301] |
| 131 | + |
| 132 | + # Overview page has moved to Index page |
| 133 | + RewriteRule ^(.*)/overview\.html(.*)$ /$1/index.html$2 [L,R=301] |
| 134 | + |
| 135 | + # Developers console redirect |
| 136 | + RewriteRule ^(latest|[0-9.]+)/getting_started/developers/developers_console\.html(.*)$ /$1/getting_started/developers_console.html$2 [L,R=301] |
| 137 | + |
| 138 | + # Deployments redirect |
| 139 | + RewriteRule ^(latest|[0-9.]+)/dev_guide/deployments\.html(.*)$ /$1/dev_guide/deployments/how_deployments_work.html$2 [L,R=301] |
| 140 | + |
| 141 | + # Builds redirect |
| 142 | + RewriteRule ^(latest|[0-9.]+)/dev_guide/builds\.html(.*)$ /$1/dev_guide/builds/index.html$2 [L,R=301] |
| 143 | + |
| 144 | + # Other specific redirects |
| 145 | + RewriteRule ^latest/admin_guide/build_defaults_overrides\.html(.*)$ /latest/install_config/build_defaults_overrides.html$1 [L,R=301] |
| 146 | + RewriteRule ^latest/admin_guide/install/(advanced_install|deploy_router|docker_registry|first_steps|overview|prerequisites|quick_install|upgrades)\.html(.*)$ /latest/install_config/install/$1.html$2 [R=301] |
| 147 | + RewriteRule ^(latest|[0-9.]+)/admin_guide/upgrades\.html(.*) /$1/install_config/upgrades.html$2 [R=301] |
| 148 | + RewriteRule ^(latest|[0-9.]+)/admin_guide/(aggregate_logging|cluster_metrics|configuring_authentication|configuring_aws|configuring_gce|configuring_openstack|http_proxies|master_node_configuration|native_container_routing|routing_from_edge_lb|syncing_groups_with_ldap|web_console_customization)\.html(.*)$ /$1/install_config/$2.html$3 [R=301] |
| 149 | + RewriteRule ^(latest|[0-9.]+)/admin_guide/persistent_storage/(persistent_storage_aws|persistent_storage_cinder|persistent_storage_gce|persistent_storage_glusterfs|persistent_storage_nfs)\.html(.*)$ /$1/install_config/persistent_storage/$2.html$3 [R=301] |
| 150 | + RewriteRule ^latest/admin_guide/selfprovisioned_projects\.html(.*)$ /$1/$2/admin_guide/managing_projects.html$3 [R=301] |
| 151 | + RewriteRule ^latest/install_config/upgrades\.html(.*)$ /latest/install_config/upgrading/index.html$1 [R=301] |
| 152 | + |
| 153 | + </Directory> |
| 154 | +</IfModule> |
| 155 | + |
| 156 | +# ---------------------------------------------------------------------- |
| 157 | +# Prevent 404 errors for non-existing redirected folders |
| 158 | +# ---------------------------------------------------------------------- |
| 159 | + |
| 160 | +# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the |
| 161 | +# same name does not exist. |
| 162 | +# webmasterworld.com/apache/3808792.htm |
| 163 | + |
| 164 | +Options -MultiViews |
| 165 | + |
| 166 | +# ---------------------------------------------------------------------- |
| 167 | +# Custom 404 page |
| 168 | +# ---------------------------------------------------------------------- |
| 169 | + |
| 170 | +# You can add custom pages to handle 500 or 403 pretty easily, if you like. |
| 171 | +# If you are hosting your site in subdirectory, adjust this accordingly |
| 172 | +# e.g. ErrorDocument 404 /subdir/404.html |
| 173 | +ErrorDocument 404 /404.html |
| 174 | + |
| 175 | + |
| 176 | +# ---------------------------------------------------------------------- |
| 177 | +# UTF-8 encoding |
| 178 | +# ---------------------------------------------------------------------- |
| 179 | + |
| 180 | +# Use UTF-8 encoding for anything served text/plain or text/html |
| 181 | +AddDefaultCharset utf-8 |
| 182 | + |
| 183 | +# Force UTF-8 for a number of file formats |
| 184 | +AddCharset utf-8 .atom .css .js .json .rss .vtt .xml |
| 185 | + |
| 186 | + |
| 187 | +# ---------------------------------------------------------------------- |
| 188 | +# A little more security |
| 189 | +# ---------------------------------------------------------------------- |
| 190 | + |
| 191 | +# "-Indexes" will have Apache block users from browsing folders without a |
| 192 | +# default document Usually you should leave this activated, because you |
| 193 | +# shouldn't allow everybody to surf through every folder on your server (which |
| 194 | +# includes rather private places like CMS system folders). |
| 195 | +<IfModule mod_autoindex.c> |
| 196 | + Options -Indexes |
| 197 | +</IfModule> |
| 198 | + |
| 199 | +# Block access to "hidden" directories or files whose names begin with a |
| 200 | +# period. This includes directories used by version control systems such as |
| 201 | +# Subversion or Git. |
| 202 | +<IfModule mod_rewrite.c> |
| 203 | + RewriteCond %{SCRIPT_FILENAME} -d [OR] |
| 204 | + RewriteCond %{SCRIPT_FILENAME} -f |
| 205 | + RewriteRule "(^|/)\." - [F] |
| 206 | +</IfModule> |
| 207 | + |
| 208 | +# Block access to backup and source files. These files may be left by some |
| 209 | +# text/html editors and pose a great security danger, when anyone can access |
| 210 | +# them. |
| 211 | +<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$"> |
| 212 | + Order allow,deny |
| 213 | + Deny from all |
| 214 | + Satisfy All |
| 215 | +</FilesMatch> |
0 commit comments