.htaccess 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # If you need custom .htaccess rules, instead of modifying this file,
  2. # create one in `./i/.htaccess` (in particular for access control such as HTTP Basic Auth),
  3. # or in `../.htaccess` for other more general rules.
  4. # See also `../.htaccess.dist` if you cannot set Apache `DocumentRoot` to here (`FreshRSS/p/`) as recommended
  5. <IfModule mod_dir.c>
  6. DirectoryIndex index.php index.html
  7. </IfModule>
  8. FileETag None
  9. AddDefaultCharset UTF-8
  10. <IfModule mod_mime.c>
  11. AddType application/javascript .js
  12. AddType application/json .map
  13. AddCharset UTF-8 .html
  14. AddCharset UTF-8 .js
  15. </IfModule>
  16. <IfModule mod_filter.c>
  17. <IfModule mod_deflate.c>
  18. AddOutputFilterByType DEFLATE application/javascript application/json application/xhtml+xml image/svg+xml text/css text/html
  19. </IfModule>
  20. </IfModule>
  21. <IfModule mod_expires.c>
  22. ExpiresActive on
  23. ExpiresDefault "access plus 1 month"
  24. ExpiresByType application/javascript "access plus 1 month"
  25. ExpiresByType application/xhtml+xml "access plus 1 month"
  26. ExpiresByType image/x-icon "access plus 1 month"
  27. ExpiresByType text/html "access plus 1 month"
  28. <FilesMatch "\.php$">
  29. ExpiresActive Off
  30. </FilesMatch>
  31. </IfModule>
  32. <IfModule mod_headers.c>
  33. <FilesMatch "\.(css|gif|html|ico|js|png|svg|woff|woff2)$">
  34. Header merge Cache-Control "public"
  35. <If "%{QUERY_STRING} =~ /^[0-9]+$/">
  36. # For requests like `frss.css?1746304092`
  37. Header merge Cache-Control "immutable"
  38. </If>
  39. </FilesMatch>
  40. </IfModule>
  41. # Provide the true IP address of the connection (e.g. last proxy), even when using mod_remoteip
  42. <IfModule mod_rewrite.c>
  43. RewriteEngine on
  44. RewriteRule .* - [E=CONN_REMOTE_ADDR:%{CONN_REMOTE_ADDR}]
  45. </IfModule>
  46. <IfModule !mod_rewrite.c>
  47. <IfModule mod_setenvif.c>
  48. SetEnvIfExpr "%{CONN_REMOTE_ADDR} =~ /(.*)/" CONN_REMOTE_ADDR=$1
  49. </IfModule>
  50. </IfModule>
  51. # Log remote user with same priority as FreshRSS_http_Util::httpAuthUser(). See also api/.htaccess
  52. <IfModule mod_setenvif.c>
  53. SetEnvIfExpr "reqenv('LOG_REMOTE_USER') == ''" LOG_REMOTE_USER=-
  54. SetEnvIfExpr "reqenv('LOG_REMOTE_USER') == '-' && reqenv('REMOTE_USER') =~ /(.+)/" LOG_REMOTE_USER=$1
  55. SetEnvIfExpr "reqenv('LOG_REMOTE_USER') == '-' && reqenv('REDIRECT_REMOTE_USER') =~ /(.+)/" LOG_REMOTE_USER=$1
  56. SetEnvIfExpr "reqenv('LOG_REMOTE_USER') == '-' && req('Remote-User') =~ /(.+)/" LOG_REMOTE_USER=$1
  57. SetEnvIfExpr "reqenv('LOG_REMOTE_USER') == '-' && req('X-WebAuth-User') =~ /(.+)/" LOG_REMOTE_USER=$1
  58. </IfModule>