Advertisement
Guest User

Untitled

a guest
Nov 15th, 2022
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. # Use the front controller as index file. It serves as a fallback solution when
  2. # every other rewrite/redirect fails (e.g. in an aliased environment without
  3. # mod_rewrite). Additionally, this reduces the matching process for the
  4. # start page (path "/") because otherwise Apache will apply the rewriting rules
  5. # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
  6. #DirectoryIndex index.php
  7.  
  8. <IfModule mod_rewrite.c>
  9. RewriteEngine On
  10.  
  11. # Set Authorization header for OAuth2 for when php is running under fcgi
  12. RewriteCond %{HTTP:Authorization} .+
  13. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  14.  
  15. # Determine the RewriteBase automatically and set it as environment variable.
  16. # If you are using Apache aliases to do mass virtual hosting or installed the
  17. # project in a subdirectory, the base path will be prepended to allow proper
  18. # resolution of the app.php file and to redirect to the correct URI. It will
  19. # work in environments without path prefix as well, providing a safe, one-size
  20. # fits all solution. But as you do not need it in this case, you can comment
  21. # the following 2 lines to eliminate the overhead.
  22. RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
  23. RewriteRule ^(.*) - [E=BASE:%1]
  24.  
  25. # Redirect to URI without front controller to prevent duplicate content
  26. # (with and without `/app.php`). Only do this redirect on the initial
  27. # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
  28. # endless redirect loop (request -> rewrite to front controller ->
  29. # redirect -> request -> ...).
  30. # So in case you get a "too many redirects" error or you always get redirected
  31. # to the start page because your Apache does not expose the REDIRECT_STATUS
  32. # environment variable, you have 2 choices:
  33. # - disable this feature by commenting the following 2 lines or
  34. # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
  35. # following RewriteCond (best solution)
  36. RewriteCond %{ENV:REDIRECT_STATUS} ^$
  37. RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
  38.  
  39. # If the requested filename exists, simply serve it.
  40. # We only want to let Apache serve files and not directories.
  41. RewriteCond %{REQUEST_FILENAME} -f
  42. RewriteRule .? - [L]
  43.  
  44. # Rewrite all other queries to the front controller.
  45. RewriteRule .? %{ENV:BASE}/index.php [L]
  46. </IfModule>
  47.  
  48. <IfModule !mod_rewrite.c>
  49. <IfModule mod_alias.c>
  50. # When mod_rewrite is not available, we instruct a temporary redirect of
  51. # the start page to the front controller explicitly so that the website
  52. # and the generated links can still be used.
  53. RedirectMatch 302 ^(?!/(index\.php|index_dev\.php|app|addons|plugins|media|upgrade))(/(.*))$ /index.php$2
  54. # RedirectTemp cannot be used instead
  55. </IfModule>
  56. </IfModule>
  57.  
  58. <IfModule mod_php5.c>
  59. # @link https://github.com/mautic/mautic/issues/1504
  60. php_value always_populate_raw_post_data -1
  61. </IfModule>
  62.  
  63. <IfModule mod_deflate.c>
  64. <IfModule mod_filter.c>
  65. AddOutputFilterByType DEFLATE application/javascript
  66. AddOutputFilterByType DEFLATE application/rss+xml
  67. AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  68. AddOutputFilterByType DEFLATE application/x-font
  69. AddOutputFilterByType DEFLATE application/x-font-opentype
  70. AddOutputFilterByType DEFLATE application/x-font-otf
  71. AddOutputFilterByType DEFLATE application/x-font-truetype
  72. AddOutputFilterByType DEFLATE application/x-font-ttf
  73. AddOutputFilterByType DEFLATE application/x-javascript
  74. AddOutputFilterByType DEFLATE font/opentype
  75. AddOutputFilterByType DEFLATE font/otf
  76. AddOutputFilterByType DEFLATE font/ttf
  77. AddOutputFilterByType DEFLATE image/svg+xml
  78. AddOutputFilterByType DEFLATE image/x-icon
  79. AddOutputFilterByType DEFLATE text/css
  80. AddOutputFilterByType DEFLATE text/javascript
  81. # Do not enable compression for file types that could contain secrets
  82. #AddOutputFilterByType DEFLATE text/html
  83. #AddOutputFilterByType DEFLATE text/plain
  84. #AddOutputFilterByType DEFLATE text/xml
  85. #AddOutputFilterByType DEFLATE application/xhtml+xml
  86. #AddOutputFilterByType DEFLATE application/xml
  87. #AddOutputFilterByType DEFLATE application/json
  88. <IfModule mod_setenvif.c>
  89. <IfModule mod_header.c>
  90. # Remove browser bugs (only needed for really old browsers)
  91. BrowserMatch ^Mozilla/4 gzip-only-text/html
  92. BrowserMatch ^Mozilla/4\.0[678] no-gzip
  93. BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  94. Header append Vary User-Agent
  95. </IfModule>
  96. </IfModule>
  97. </IfModule>
  98. </IfModule>
  99.  
  100. # Apache 2.4+
  101. <IfModule authz_core_module>
  102. # Deny access via HTTP requests to all PHP files.
  103. <FilesMatch "\.php$">
  104. # Require all denied
  105. </FilesMatch>
  106.  
  107. # Deny access via HTTP requests to composer files.
  108. <FilesMatch "^(composer\.json|composer\.lock)$">
  109. Require all denied
  110. </FilesMatch>
  111.  
  112. # Except those allowed below.
  113. <If "%{REQUEST_URI} =~ m#^/(index|index_dev|upgrade/upgrade)\.php#">
  114. Require all granted
  115. </If>
  116. </IfModule>
  117.  
  118. # Fallback for Apache < 2.4
  119. <IfModule !authz_core_module>
  120. # Deny access via HTTP requests to all PHP files.
  121. <FilesMatch "\.php$">
  122. Order deny,allow
  123. Deny from all
  124. </FilesMatch>
  125.  
  126. # Deny access via HTTP requests to composer files
  127. <FilesMatch "^(composer\.json|composer\.lock)$">
  128. Order deny,allow
  129. Deny from all
  130. </FilesMatch>
  131.  
  132. # Except those allowed below.
  133. <If "%{REQUEST_URI} =~ m#^/(index|index_dev|upgrade/upgrade)\.php#">
  134. Order allow,deny
  135. Allow from all
  136. </If>
  137. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement