.htaccess 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. ## Begin RewriteBase
  4. # If you are getting 500 or 404 errors on subpages, you may have to uncomment the RewriteBase entry
  5. # You should change the '/' to your appropriate subfolder. For example if you have
  6. # your Grav install at the root of your site '/' should work, else it might be something
  7. # along the lines of: RewriteBase /<your_sub_folder>
  8. ##
  9. # RewriteBase /
  10. ## End - RewriteBase
  11. ## Begin - X-Forwarded-Proto
  12. # In some hosted or load balanced environments, SSL negotiation happens upstream.
  13. # In order for Grav to recognize the connection as secure, you need to uncomment
  14. # the following lines.
  15. #
  16. # RewriteCond %{HTTP:X-Forwarded-Proto} https
  17. # RewriteRule .* - [E=HTTPS:on]
  18. #
  19. ## End - X-Forwarded-Proto
  20. ## Begin - Exploits
  21. # If you experience problems on your site block out the operations listed below
  22. # This attempts to block the most common type of exploit `attempts` to Grav
  23. #
  24. # Block out any script trying to base64_encode data within the URL.
  25. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
  26. # Block out any script that includes a <script> tag in URL.
  27. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
  28. # Block out any script trying to set a PHP GLOBALS variable via URL.
  29. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
  30. # Block out any script trying to modify a _REQUEST variable via URL.
  31. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
  32. # Return 403 Forbidden header and show the content of the root homepage
  33. RewriteRule .* index.php [F]
  34. #
  35. ## End - Exploits
  36. ## Begin - Index
  37. # If the requested path and file is not /index.php and the request
  38. # has not already been internally rewritten to the index.php script
  39. RewriteCond %{REQUEST_URI} !^/index\.php
  40. # and the requested path and file doesn't directly match a physical file
  41. RewriteCond %{REQUEST_FILENAME} !-f
  42. # and the requested path and file doesn't directly match a physical folder
  43. RewriteCond %{REQUEST_FILENAME} !-d
  44. # internally rewrite the request to the index.php script
  45. RewriteRule .* index.php [L]
  46. ## End - Index
  47. ## Begin - Security
  48. # Block all direct access for these folders
  49. RewriteRule ^(\.git|cache|bin|logs|backup|webserver-configs|tests)/(.*) error [F]
  50. # Block access to specific file types for these system folders
  51. RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
  52. # Block access to specific file types for these user folders
  53. RewriteRule ^(user)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ error [F]
  54. # Block all direct access to .md files:
  55. RewriteRule \.md$ error [F]
  56. # Block all direct access to files and folders beginning with a dot
  57. RewriteRule (^|/)\.(?!well-known) - [F]
  58. # Block access to specific files in the root folder
  59. RewriteRule ^(LICENSE\.txt|composer\.lock|composer\.json|\.htaccess)$ error [F]
  60. ## End - Security
  61. </IfModule>
  62. # Begin - Prevent Browsing and Set Default Resources
  63. Options -Indexes
  64. DirectoryIndex index.php index.html index.htm
  65. # End - Prevent Browsing and Set Default Resources
  66. # Redirect http://figureslibres.kevintessier.net/ https://figureslibres.kevintessier.net/
  67. Redirect 301 /sitemap /sitemap.xml