annotate .htaccess @ 1:f38015048f48 tip

Added GPL
author Daniel Wolff
date Sat, 13 Feb 2016 20:43:38 +0100
parents 493bcb69166c
children
rev   line source
Daniel@0 1 <IfModule mod_authz_core.c>
Daniel@0 2 Require all granted
Daniel@0 3 </IfModule>
Daniel@0 4 <IfModule !mod_authz_core.c>
Daniel@0 5 Order allow,deny
Daniel@0 6 Allow from all
Daniel@0 7 </IfModule>
Daniel@0 8
Daniel@0 9 Options -Indexes
Daniel@0 10 Options +FollowSymLinks
Daniel@0 11 ErrorDocument 403 /404/
Daniel@0 12 ErrorDocument 404 /404/
Daniel@0 13
Daniel@0 14 # Use the front controller as index file. It serves as a fallback solution when
Daniel@0 15 # every other rewrite/redirect fails (e.g. in an aliased environment without
Daniel@0 16 # mod_rewrite). Additionally, this reduces the matching process for the
Daniel@0 17 # start page (path "/") because otherwise Apache will apply the rewriting rules
Daniel@0 18 # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
Daniel@0 19 DirectoryIndex a_prod.php
Daniel@0 20
Daniel@0 21 <IfModule mod_rewrite.c>
Daniel@0 22 RewriteEngine On
Daniel@0 23
Daniel@0 24 # Determine the RewriteBase automatically and set it as environment variable.
Daniel@0 25 # If you are using Apache aliases to do mass virtual hosting or installed the
Daniel@0 26 # project in a subdirectory, the base path will be prepended to allow proper
Daniel@0 27 # resolution of the a_prod.php file and to redirect to the correct URI. It will
Daniel@0 28 # work in environments without path prefix as well, providing a safe, one-size
Daniel@0 29 # fits all solution. But as you do not need it in this case, you can comment
Daniel@0 30 # the following 2 lines to eliminate the overhead.
Daniel@0 31 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
Daniel@0 32 RewriteRule ^(.*) - [E=BASE:%1]
Daniel@0 33
Daniel@0 34 # Redirect to URI without front controller to prevent duplicate content
Daniel@0 35 # (with and without `/a_prod.php`). Only do this redirect on the initial
Daniel@0 36 # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
Daniel@0 37 # endless redirect loop (request -> rewrite to front controller ->
Daniel@0 38 # redirect -> request -> ...).
Daniel@0 39 # So in case you get a "too many redirects" error or you always get redirected
Daniel@0 40 # to the start page because your Apache does not expose the REDIRECT_STATUS
Daniel@0 41 # environment variable, you have 2 choices:
Daniel@0 42 # - disable this feature by commenting the following 2 lines or
Daniel@0 43 # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
Daniel@0 44 # following RewriteCond (best solution)
Daniel@0 45 RewriteCond %{ENV:REDIRECT_STATUS} ^$
Daniel@0 46 RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
Daniel@0 47
Daniel@0 48 # If the requested filename exists, simply serve it.
Daniel@0 49 # We only want to let Apache serve files and not directories.
Daniel@0 50 RewriteCond %{REQUEST_FILENAME} -f
Daniel@0 51 RewriteRule .? - [L]
Daniel@0 52
Daniel@0 53 # Rewrite all other queries to the front controller.
Daniel@0 54 RewriteRule .? %{ENV:BASE}/a_prod.php [L]
Daniel@0 55 </IfModule>
Daniel@0 56
Daniel@0 57 ## App entry point
Daniel@0 58 <IfModule !mod_rewrite.c>
Daniel@0 59 <IfModule mod_alias.c>
Daniel@0 60 # When mod_rewrite is not available, we instruct a temporary redirect of
Daniel@0 61 # the start page to the front controller explicitly so that the website
Daniel@0 62 # and the generated links can still be used.
Daniel@0 63 RedirectMatch 302 ^/$ /a_prod.php/
Daniel@0 64 # RedirectTemp cannot be used instead
Daniel@0 65 </IfModule>
Daniel@0 66 </IfModule>
Daniel@0 67
Daniel@0 68 ## HTTP Caching
Daniel@0 69 <ifModule mod_headers.c>
Daniel@0 70 <filesMatch "\.(ico|jpe?g|jpg|png|gif|swf|css|js)$">
Daniel@0 71 Header unset Pragma
Daniel@0 72 FileETag None
Daniel@0 73 Header unset ETag
Daniel@0 74 #10 years
Daniel@0 75 Header set Cache-Control "max-age=315360000, public, must-revalidate"
Daniel@0 76 #Header set Cache-Control "max-age=315360000, public"
Daniel@0 77 Header unset Last-Modified
Daniel@0 78 </filesMatch>
Daniel@0 79 </IfModule>
Daniel@0 80
Daniel@0 81 ## Gzip
Daniel@0 82 <ifmodule mod_deflate.c>
Daniel@0 83 AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
Daniel@0 84 </ifmodule>
Daniel@0 85
Daniel@0 86 ## Deny access to some files and folders
Daniel@0 87 <FilesMatch "\.buildpath|\.hgignore|\.project|composer\..*|readme\.txt|SYMFONY-LICENSE">
Daniel@0 88 Order allow,deny
Daniel@0 89 Deny from all
Daniel@0 90 </FilesMatch>
Daniel@0 91 RedirectMatch 404 /\\.hg(/.*|$)
Daniel@0 92 RedirectMatch 404 /\\.hgcheck(/.*|$)
Daniel@0 93 RedirectMatch 404 /\\.settings(/.*|$)