.htaccess 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. # By default, Apache does not evaluate symbolic links if you did not enable this
  8. # feature in your server configuration. Uncomment the following line if you
  9. # install assets as symlinks or if you experience problems related to symlinks
  10. # when compiling LESS/Sass/CoffeScript assets.
  11. # Options +SymLinksIfOwnerMatch
  12. # Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
  13. # to the front controller "/index.php" but be rewritten to "/index.php/index".
  14. <IfModule mod_negotiation.c>
  15. Options -MultiViews
  16. </IfModule>
  17. <IfModule mod_rewrite.c>
  18. # This Option needs to be enabled for RewriteRule, otherwise it will show an error like
  19. # 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden'
  20. Options +SymLinksIfOwnerMatch
  21. RewriteEngine On
  22. # Determine the RewriteBase automatically and set it as environment variable.
  23. # If you are using Apache aliases to do mass virtual hosting or installed the
  24. # project in a subdirectory, the base path will be prepended to allow proper
  25. # resolution of the index.php file and to redirect to the correct URI. It will
  26. # work in environments without path prefix as well, providing a safe, one-size
  27. # fits all solution. But as you do not need it in this case, you can comment
  28. # the following 2 lines to eliminate the overhead.
  29. RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
  30. RewriteRule .* - [E=BASE:%1]
  31. # Sets the HTTP_AUTHORIZATION header removed by Apache
  32. RewriteCond %{HTTP:Authorization} .+
  33. RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
  34. # Redirect to URI without front controller to prevent duplicate content
  35. # (with and without `/index.php`). Only do this redirect on the initial
  36. # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
  37. # endless redirect loop (request -> rewrite to front controller ->
  38. # redirect -> request -> ...).
  39. # So in case you get a "too many redirects" error or you always get redirected
  40. # to the start page because your Apache does not expose the REDIRECT_STATUS
  41. # environment variable, you have 2 choices:
  42. # - disable this feature by commenting the following 2 lines or
  43. # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
  44. # following RewriteCond (best solution)
  45. RewriteCond %{ENV:REDIRECT_STATUS} =""
  46. RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
  47. # If the requested filename exists, simply serve it.
  48. # We only want to let Apache serve files and not directories.
  49. # Rewrite all other queries to the front controller.
  50. RewriteCond %{REQUEST_FILENAME} !-f
  51. RewriteRule ^ %{ENV:BASE}/index.php [L]
  52. </IfModule>
  53. <IfModule !mod_rewrite.c>
  54. <IfModule mod_alias.c>
  55. # When mod_rewrite is not available, we instruct a temporary redirect of
  56. # the start page to the front controller explicitly so that the website
  57. # and the generated links can still be used.
  58. RedirectMatch 307 ^/$ /index.php/
  59. # RedirectTemp cannot be used instead
  60. </IfModule>
  61. </IfModule>