Advertisement
Guest User

.htaccess

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