.htaccess 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <IfModule mod_headers.c>
  2. <IfModule mod_setenvif.c>
  3. <IfModule mod_fcgid.c>
  4. SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
  5. RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
  6. </IfModule>
  7. <IfModule mod_proxy_fcgi.c>
  8. SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
  9. </IfModule>
  10. <IfModule mod_lsapi.c>
  11. SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
  12. RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
  13. </IfModule>
  14. </IfModule>
  15. <IfModule mod_env.c>
  16. # Add security and privacy related headers
  17. # Avoid doubled headers by unsetting headers in "onsuccess" table,
  18. # then add headers to "always" table: https://github.com/nextcloud/server/pull/19002
  19. Header onsuccess unset Referrer-Policy
  20. Header always set Referrer-Policy "no-referrer"
  21. Header onsuccess unset X-Content-Type-Options
  22. Header always set X-Content-Type-Options "nosniff"
  23. Header onsuccess unset X-Frame-Options
  24. Header always set X-Frame-Options "SAMEORIGIN"
  25. Header onsuccess unset X-Permitted-Cross-Domain-Policies
  26. Header always set X-Permitted-Cross-Domain-Policies "none"
  27. Header onsuccess unset X-Robots-Tag
  28. Header always set X-Robots-Tag "none"
  29. Header onsuccess unset X-XSS-Protection
  30. Header always set X-XSS-Protection "1; mode=block"
  31. SetEnv modHeadersAvailable true
  32. </IfModule>
  33. # Add cache control for static resources
  34. <FilesMatch "\.(css|js|svg|gif|png|jpg|ico|wasm|tflite)$">
  35. Header set Cache-Control "max-age=15778463"
  36. </FilesMatch>
  37. <FilesMatch "\.(css|js|svg|gif|png|jpg|ico|wasm|tflite)(\?v=.*)?$">
  38. Header set Cache-Control "max-age=15778463, immutable"
  39. </FilesMatch>
  40. # Let browsers cache WOFF files for a week
  41. <FilesMatch "\.woff2?$">
  42. Header set Cache-Control "max-age=604800"
  43. </FilesMatch>
  44. </IfModule>
  45. # PHP 7.x
  46. <IfModule mod_php7.c>
  47. php_value mbstring.func_overload 0
  48. php_value default_charset 'UTF-8'
  49. php_value output_buffering 0
  50. <IfModule mod_env.c>
  51. SetEnv htaccessWorking true
  52. </IfModule>
  53. </IfModule>
  54. # PHP 8+
  55. <IfModule mod_php.c>
  56. php_value mbstring.func_overload 0
  57. php_value default_charset 'UTF-8'
  58. php_value output_buffering 0
  59. <IfModule mod_env.c>
  60. SetEnv htaccessWorking true
  61. </IfModule>
  62. </IfModule>
  63. <IfModule mod_mime.c>
  64. AddType image/svg+xml svg svgz
  65. AddType application/wasm wasm
  66. AddEncoding gzip svgz
  67. </IfModule>
  68. <IfModule mod_dir.c>
  69. DirectoryIndex index.php index.html
  70. </IfModule>
  71. <IfModule pagespeed_module>
  72. ModPagespeed Off
  73. </IfModule>
  74. <IfModule mod_rewrite.c>
  75. RewriteEngine on
  76. RewriteCond %{HTTP_USER_AGENT} DavClnt
  77. RewriteRule ^$ /remote.php/webdav/ [L,R=302]
  78. RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  79. RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  80. RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  81. RewriteRule ^remote/(.*) remote.php [QSA,L]
  82. RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  83. RewriteRule ^\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
  84. RewriteRule ^(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
  85. </IfModule>
  86. AddDefaultCharset utf-8
  87. Options -Indexes