partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

.htaccess (3127B)


      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 app.php
      7 
      8 # Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
      9 # to the front controller "/app.php" but be rewritten to "/app.php/app".
     10 <IfModule mod_negotiation.c>
     11     Options -MultiViews
     12 </IfModule>
     13 
     14 <IfModule mod_rewrite.c>
     15     RewriteEngine On
     16 
     17     RewriteRule ^setup\/$ setup/index.html
     18 
     19     RewriteRule ^setup\/webserver-test$ setup/tests/webservercheck.json
     20     # Determine the RewriteBase automatically and set it as environment variable.
     21     # If you are using Apache aliases to do mass virtual hosting or installed the
     22     # project in a subdirectory, the base path will be prepended to allow proper
     23     # resolution of the app.php file and to redirect to the correct URI. It will
     24     # work in environments without path prefix as well, providing a safe, one-size
     25     # fits all solution. But as you do not need it in this case, you can comment
     26     # the following 2 lines to eliminate the overhead.
     27     RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
     28     RewriteRule ^(.*) - [E=BASE:%1]
     29 
     30     # Sets the HTTP_AUTHORIZATION header removed by apache
     31     RewriteCond %{HTTP:Authorization} .
     32     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
     33 
     34     # Redirect to URI without front controller to prevent duplicate content
     35     # (with and without `/app.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 ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
     47 
     48     # If the requested filename exists, simply serve it.
     49     # We only want to let Apache serve files and not directories.
     50     RewriteCond %{REQUEST_FILENAME} -f
     51     RewriteRule .? - [L]
     52 
     53     # Rewrite all other queries to the front controller.
     54     RewriteRule .? %{ENV:BASE}/app.php [L]
     55 </IfModule>
     56 
     57 <IfModule !mod_rewrite.c>
     58     <IfModule mod_alias.c>
     59         # When mod_rewrite is not available, we instruct a temporary redirect of
     60         # the start page to the front controller explicitly so that the website
     61         # and the generated links can still be used.
     62         RedirectMatch 302 ^/$ /app.php/
     63         # RedirectTemp cannot be used instead
     64     </IfModule>
     65 </IfModule>