.htaccess 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # MODX supports Friendly URLs via this .htaccess file. You must serve web
  2. # pages via Apache with mod_rewrite to use this functionality, and you must
  3. # change the file name from ht.access to .htaccess.
  4. #
  5. # Make sure RewriteBase points to the directory where you installed MODX.
  6. # E.g., "/modx" if your installation is in a "modx" subdirectory.
  7. #
  8. # You may choose to make your URLs non-case-sensitive by adding a NC directive
  9. # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
  10. RewriteEngine On
  11. RewriteBase /
  12. # Prevent rewrite the .well-known directory used by LetsEncrypt by rules below of this rule
  13. RewriteRule "^\.well-known/" - [L]
  14. # Prevent dot directories (hidden directories like .git) to be exposed to the public
  15. # Except for the .well-known directory used by LetsEncrypt a.o
  16. RewriteRule "/\.|^\.(?!well-known/)" - [F]
  17. # Rewrite www.example.com -> example.com -- used with SEO Strict URLs plugin
  18. RewriteCond %{HTTP_HOST} .
  19. RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
  20. RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  21. #
  22. # or for the opposite example.com -> www.example.com use the following
  23. # DO NOT USE BOTH
  24. #
  25. #RewriteCond %{HTTP_HOST} !^$
  26. #RewriteCond %{HTTP_HOST} !^www\. [NC]
  27. #RewriteCond %{HTTP_HOST} (.+)$
  28. #RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L] .
  29. # Force rewrite to https for every host
  30. RewriteCond %{HTTPS} !=on [OR]
  31. RewriteCond %{SERVER_PORT} !^443
  32. RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  33. # Redirect the manager to a specific domain - don't rename the ht.access file
  34. # in the manager folder to use this this rule
  35. #RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
  36. #RewriteCond %{REQUEST_URI} ^/manager [NC]
  37. #RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
  38. # The Friendly URLs part
  39. RewriteCond %{REQUEST_FILENAME} !-f
  40. RewriteCond %{REQUEST_FILENAME} !-d
  41. RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  42. # For servers that support output compression, you should pick up a bit of
  43. # speed by un-commenting the following lines.
  44. # php_flag zlib.output_compression On
  45. # php_value zlib.output_compression_level 5