|
| 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_test.php |
| 7 | + |
| 8 | +# By default, Apache does not evaluate symbolic links if you did not enable this |
| 9 | +# feature in your server configuration. Uncomment the following line if you |
| 10 | +# install assets as symlinks or if you experience problems related to symlinks |
| 11 | +# when compiling LESS/Sass/CoffeScript assets. |
| 12 | +# Options FollowSymlinks |
| 13 | + |
| 14 | +# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve |
| 15 | +# to the front controller "/app.php" but be rewritten to "/app.php/app". |
| 16 | +<IfModule mod_negotiation.c> |
| 17 | + Options -MultiViews |
| 18 | +</IfModule> |
| 19 | + |
| 20 | +# mime types |
| 21 | +AddType video/mp4 .mp4 |
| 22 | +AddType video/webm .webm |
| 23 | +AddType image/jpeg .pjpeg |
| 24 | + |
| 25 | +Options +SymLinksIfOwnerMatch |
| 26 | + |
| 27 | +# Use UTF-8 encoding for anything served text/plain or text/html |
| 28 | +AddDefaultCharset utf-8 |
| 29 | + |
| 30 | +RewriteEngine On |
| 31 | + |
| 32 | +<IfModule mod_headers.c> |
| 33 | + <FilesMatch "\.(jpe?g|png)$"> |
| 34 | + Header always unset X-Content-Type-Options |
| 35 | + </FilesMatch> |
| 36 | +</IfModule> |
| 37 | + |
| 38 | +# Determine the RewriteBase automatically and set it as environment variable. |
| 39 | +# If you are using Apache aliases to do mass virtual hosting or installed the |
| 40 | +# project in a subdirectory, the base path will be prepended to allow proper |
| 41 | +# resolution of the app.php file and to redirect to the correct URI. It will |
| 42 | +# work in environments without path prefix as well, providing a safe, one-size |
| 43 | +# fits all solution. But as you do not need it in this case, you can comment |
| 44 | +# the following 2 lines to eliminate the overhead. |
| 45 | +RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ |
| 46 | +RewriteRule ^(.*) - [E=BASE:%1] |
| 47 | + |
| 48 | +# Sets the HTTP_AUTHORIZATION header removed by Apache |
| 49 | +RewriteCond %{HTTP:Authorization} . |
| 50 | +RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] |
| 51 | + |
| 52 | +# Redirect to URI without front controller to prevent duplicate content |
| 53 | +# (with and without `/app.php`). Only do this redirect on the initial |
| 54 | +# rewrite by Apache and not on subsequent cycles. Otherwise we would get an |
| 55 | +# endless redirect loop (request -> rewrite to front controller -> |
| 56 | +# redirect -> request -> ...). |
| 57 | +# So in case you get a "too many redirects" error or you always get redirected |
| 58 | +# to the start page because your Apache does not expose the REDIRECT_STATUS |
| 59 | +# environment variable, you have 2 choices: |
| 60 | +# - disable this feature by commenting the following 2 lines or |
| 61 | +# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the |
| 62 | +# following RewriteCond (best solution) |
| 63 | +RewriteCond %{ENV:REDIRECT_STATUS} ^$ |
| 64 | +RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] |
| 65 | + |
| 66 | +<IfModule mod_status.c> |
| 67 | + RewriteCond %{REQUEST_URI} ^/(fpm|server)-(info|status|ping) |
| 68 | + RewriteRule . - [L] |
| 69 | +</IfModule> |
| 70 | + |
| 71 | +# restrict access to dotfiles |
| 72 | +RewriteCond %{REQUEST_FILENAME} -d [OR] |
| 73 | +RewriteCond %{REQUEST_FILENAME} -l [OR] |
| 74 | +RewriteCond %{REQUEST_FILENAME} -f |
| 75 | +RewriteRule /\.|^\.(?!well-known/) - [F,L] |
| 76 | + |
| 77 | +# ASSETS: check if request method is GET (because of WebDAV) and if the requested file (asset) exists on the filesystem, if both match, deliver the asset directly |
| 78 | +RewriteCond %{REQUEST_METHOD} ^(GET|HEAD) |
| 79 | +RewriteCond %{DOCUMENT_ROOT}/var/assets%{REQUEST_URI} -f |
| 80 | +RewriteRule ^(.*)$ /var/assets%{REQUEST_URI} [PT,L] |
| 81 | + |
| 82 | +# Thumbnails |
| 83 | +RewriteCond %{REQUEST_URI} .*/(image|video)-thumb__[\d]+__.* |
| 84 | +RewriteCond %{DOCUMENT_ROOT}/var/tmp/%1-thumbnails%{REQUEST_URI} -f |
| 85 | +RewriteRule ^(.*)$ /var/tmp/%1-thumbnails%{REQUEST_URI} [PT,L] |
| 86 | + |
| 87 | +# cache-buster rule for scripts & stylesheets embedded using view helpers |
| 88 | +RewriteRule ^cache-buster\-[\d]+/(.*) $1 [PT,L] |
| 89 | + |
| 90 | +# If the requested filename exists, simply serve it. |
| 91 | +# We only want to let Apache serve files and not directories. |
| 92 | +RewriteCond %{REQUEST_FILENAME} -f |
| 93 | +RewriteRule ^ - [L] |
| 94 | + |
| 95 | +# Rewrite all other queries to the front controller. |
| 96 | +RewriteRule ^ %{ENV:BASE}/index_test.php [L] |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +########################################## |
| 102 | +### OPTIONAL PERFORMANCE OPTIMIZATIONS ### |
| 103 | +########################################## |
| 104 | + |
| 105 | +<IfModule mod_deflate.c> |
| 106 | + # Force compression for mangled headers. |
| 107 | + # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping |
| 108 | + <IfModule mod_setenvif.c> |
| 109 | + <IfModule mod_headers.c> |
| 110 | + SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding |
| 111 | + RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding |
| 112 | + </IfModule> |
| 113 | + </IfModule> |
| 114 | + |
| 115 | + # Compress all output labeled with one of the following MIME-types |
| 116 | + # (for Apache versions below 2.3.7, you don't need to enable `mod_filter` |
| 117 | + # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines |
| 118 | + # as `AddOutputFilterByType` is still in the core directives). |
| 119 | + <IfModule mod_filter.c> |
| 120 | + AddOutputFilterByType DEFLATE application/atom+xml application/javascript application/json \ |
| 121 | + application/vnd.ms-fontobject application/x-font-ttf application/rss+xml \ |
| 122 | + application/x-web-app-manifest+json application/xhtml+xml \ |
| 123 | + application/xml font/opentype image/svg+xml image/x-icon \ |
| 124 | + text/css text/html text/plain text/x-component text/xml text/javascript |
| 125 | + </IfModule> |
| 126 | +</IfModule> |
| 127 | + |
| 128 | +<IfModule mod_expires.c> |
| 129 | + ExpiresActive on |
| 130 | + ExpiresDefault "access plus 31536000 seconds" |
| 131 | + |
| 132 | + # specific overrides |
| 133 | + #ExpiresByType text/css "access plus 1 year" |
| 134 | +</IfModule> |
| 135 | + |
| 136 | +<IfModule pagespeed_module> |
| 137 | + # pimcore mod_pagespeed integration |
| 138 | + # pimcore automatically disables mod_pagespeed in the following situations: debug-mode on, /admin, preview, editmode, ... |
| 139 | + # if you want to disable pagespeed for specific actions in pimcore you can use $this->disableBrowserCache() in your action |
| 140 | + RewriteCond %{REQUEST_URI} ^/(mod_)?pagespeed_(statistics|message|console|beacon|admin|global_admin) |
| 141 | + RewriteRule . - [L] |
| 142 | + |
| 143 | + ModPagespeed Off |
| 144 | + AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html |
| 145 | + ModPagespeedModifyCachingHeaders off |
| 146 | + ModPagespeedRewriteLevel PassThrough |
| 147 | + # low risk filters |
| 148 | + ModPagespeedEnableFilters remove_comments,recompress_images |
| 149 | + # low and moderate filters, recommended filters, but can cause problems |
| 150 | + ModPagespeedEnableFilters lazyload_images,extend_cache_images,inline_preview_images,sprite_images |
| 151 | + ModPagespeedEnableFilters combine_css,rewrite_css,move_css_to_head,flatten_css_imports,extend_cache_css,prioritize_critical_css |
| 152 | + ModPagespeedEnableFilters extend_cache_scripts,combine_javascript,canonicalize_javascript_libraries,rewrite_javascript |
| 153 | + # high risk |
| 154 | + #ModPagespeedEnableFilters defer_javascript,local_storage_cache |
| 155 | +</IfModule> |
0 commit comments