A Drupal-CiviCRM setup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
6.0KB

  1. #
  2. # Apache/PHP/Drupal settings:
  3. #
  4. # Protect files and directories from prying eyes.
  5. <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
  6. <IfModule mod_authz_core.c>
  7. Require all denied
  8. </IfModule>
  9. <IfModule !mod_authz_core.c>
  10. Order allow,deny
  11. </IfModule>
  12. </FilesMatch>
  13. # Don't show directory listings for URLs which map to a directory.
  14. Options -Indexes
  15. # Follow symbolic links in this directory.
  16. Options +FollowSymLinks
  17. # Make Drupal handle any 404 errors.
  18. ErrorDocument 404 /index.php
  19. # Set the default handler.
  20. DirectoryIndex index.php index.html index.htm
  21. # Override PHP settings that cannot be changed at runtime. See
  22. # sites/default/default.settings.php and drupal_environment_initialize() in
  23. # includes/bootstrap.inc for settings that can be changed at runtime.
  24. # PHP 5, Apache 1 and 2.
  25. <IfModule mod_php5.c>
  26. php_flag magic_quotes_gpc off
  27. php_flag magic_quotes_sybase off
  28. php_flag register_globals off
  29. php_flag session.auto_start off
  30. php_value mbstring.http_input pass
  31. php_value mbstring.http_output pass
  32. php_flag mbstring.encoding_translation off
  33. </IfModule>
  34. # Requires mod_expires to be enabled.
  35. <IfModule mod_expires.c>
  36. # Enable expirations.
  37. ExpiresActive On
  38. # Cache all files for 2 weeks after access (A).
  39. ExpiresDefault A1209600
  40. <FilesMatch \.php$>
  41. # Do not allow PHP scripts to be cached unless they explicitly send cache
  42. # headers themselves. Otherwise all scripts would have to overwrite the
  43. # headers set by mod_expires if they want another caching behavior. This may
  44. # fail if an error occurs early in the bootstrap process, and it may cause
  45. # problems if a non-Drupal PHP file is installed in a subdirectory.
  46. ExpiresActive Off
  47. </FilesMatch>
  48. </IfModule>
  49. # Various rewrite rules.
  50. <IfModule mod_rewrite.c>
  51. RewriteEngine on
  52. # Set "protossl" to "s" if we were accessed via https://. This is used later
  53. # if you enable "www." stripping or enforcement, in order to ensure that
  54. # you don't bounce between http and https.
  55. RewriteRule ^ - [E=protossl]
  56. RewriteCond %{HTTPS} on
  57. RewriteRule ^ - [E=protossl:s]
  58. # Make sure Authorization HTTP header is available to PHP
  59. # even when running as CGI or FastCGI.
  60. RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  61. # Block access to "hidden" directories whose names begin with a period. This
  62. # includes directories used by version control systems such as Subversion or
  63. # Git to store control files. Files whose names begin with a period, as well
  64. # as the control files used by CVS, are protected by the FilesMatch directive
  65. # above.
  66. #
  67. # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
  68. # not possible to block access to entire directories from .htaccess, because
  69. # <DirectoryMatch> is not allowed here.
  70. #
  71. # If you do not have mod_rewrite installed, you should remove these
  72. # directories from your webroot or otherwise protect them from being
  73. # downloaded.
  74. RewriteRule "/\.|^\.(?!well-known/)" - [F]
  75. # If your site can be accessed both with and without the 'www.' prefix, you
  76. # can use one of the following settings to redirect users to your preferred
  77. # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  78. #
  79. # To redirect all users to access the site WITH the 'www.' prefix,
  80. # (http://example.com/... will be redirected to http://www.example.com/...)
  81. # uncomment the following:
  82. # RewriteCond %{HTTP_HOST} .
  83. # RewriteCond %{HTTP_HOST} !^www\. [NC]
  84. # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  85. #
  86. # To redirect all users to access the site WITHOUT the 'www.' prefix,
  87. # (http://www.example.com/... will be redirected to http://example.com/...)
  88. # uncomment the following:
  89. # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  90. # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  91. # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  92. # VirtualDocumentRoot and the rewrite rules are not working properly.
  93. # For example if your site is at http://example.com/drupal uncomment and
  94. # modify the following line:
  95. # RewriteBase /drupal
  96. #
  97. # If your site is running in a VirtualDocumentRoot at http://example.com/,
  98. # uncomment the following line:
  99. # RewriteBase /
  100. # Pass all requests not referring directly to files in the filesystem to
  101. # index.php. Clean URLs are handled in drupal_environment_initialize().
  102. RewriteCond %{REQUEST_FILENAME} !-f
  103. RewriteCond %{REQUEST_FILENAME} !-d
  104. RewriteCond %{REQUEST_URI} !=/favicon.ico
  105. RewriteRule ^ index.php [L]
  106. # Rules to correctly serve gzip compressed CSS and JS files.
  107. # Requires both mod_rewrite and mod_headers to be enabled.
  108. <IfModule mod_headers.c>
  109. # Serve gzip compressed CSS files if they exist and the client accepts gzip.
  110. RewriteCond %{HTTP:Accept-encoding} gzip
  111. RewriteCond %{REQUEST_FILENAME}\.gz -s
  112. RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
  113. # Serve gzip compressed JS files if they exist and the client accepts gzip.
  114. RewriteCond %{HTTP:Accept-encoding} gzip
  115. RewriteCond %{REQUEST_FILENAME}\.gz -s
  116. RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
  117. # Serve correct content types, and prevent mod_deflate double gzip.
  118. RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
  119. RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
  120. <FilesMatch "(\.js\.gz|\.css\.gz)$">
  121. # Serve correct encoding type.
  122. Header set Content-Encoding gzip
  123. # Force proxies to cache gzipped & non-gzipped css/js files separately.
  124. Header append Vary Accept-Encoding
  125. </FilesMatch>
  126. </IfModule>
  127. </IfModule>
  128. # Add headers to all responses.
  129. <IfModule mod_headers.c>
  130. # Disable content sniffing, since it's an attack vector.
  131. Header always set X-Content-Type-Options nosniff
  132. </IfModule>