.htaccess 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. SetEnv TYPO3_CONTEXT Development
  2. # Enable / Disable the opentalent ot_optimizer middlewares
  3. SetEnv TYPO3_OPTIMIZE 1
  4. #####
  5. #
  6. # Example .htaccess file for TYPO3 CMS - for use with Apache Webserver
  7. #
  8. # This file includes settings for the following configuration options:
  9. #
  10. # - Compression
  11. # - Caching
  12. # - MIME types
  13. # - Cross Origin requests
  14. # - Rewriting and Access
  15. # - Miscellaneous
  16. # - PHP optimisation
  17. #
  18. # If you want to use it, you have to copy it to the root folder of your TYPO3 installation (if its
  19. # not there already) and rename it to '.htaccess'. To make .htaccess files work, you might need to
  20. # adjust the 'AllowOverride' directive in your Apache configuration file.
  21. #
  22. # IMPORTANT: You may need to change this file depending on your TYPO3 installation!
  23. # Consider adding this file's content to your webserver's configuration directly for speed improvement
  24. #
  25. # Lots of the options are taken from https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess
  26. #
  27. ####
  28. ### Begin: Compression ###
  29. # Compressing resource files will save bandwidth and so improve loading speed especially for users
  30. # with slower internet connections. TYPO3 can compress the .js and .css files for you.
  31. # *) Uncomment the following lines and
  32. # *) Set $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = 9 for the Backend
  33. # *) Set $GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'] = 9 together with the TypoScript properties
  34. # config.compressJs and config.compressCss for GZIP compression of Frontend JS and CSS files.
  35. <FilesMatch "\.js\.gz">
  36. AddType "text/javascript" .gz
  37. </FilesMatch>
  38. <FilesMatch "\.css\.gz">
  39. AddType "text/css" .gz
  40. </FilesMatch>
  41. AddEncoding x-gzip .gz
  42. <IfModule mod_deflate.c>
  43. # Force compression for mangled `Accept-Encoding` request headers
  44. <IfModule mod_setenvif.c>
  45. <IfModule mod_headers.c>
  46. SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  47. RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  48. </IfModule>
  49. </IfModule>
  50. # Compress all output labeled with one of the following media types.
  51. #
  52. # (!) For Apache versions below version 2.3.7 you don't need to
  53. # enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
  54. # and `</IfModule>` lines as `AddOutputFilterByType` is still in
  55. # the core directives.
  56. #
  57. # https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
  58. <IfModule mod_filter.c>
  59. AddOutputFilterByType DEFLATE application/atom+xml \
  60. application/javascript \
  61. application/json \
  62. application/ld+json \
  63. application/manifest+json \
  64. application/rdf+xml \
  65. application/rss+xml \
  66. application/schema+json \
  67. application/vnd.geo+json \
  68. application/geo+json \
  69. application/vnd.ms-fontobject \
  70. application/x-font-ttf \
  71. application/x-javascript \
  72. application/x-web-app-manifest+json \
  73. application/xhtml+xml \
  74. application/xml \
  75. font/eot \
  76. font/opentype \
  77. font/otf \
  78. font/ttf \
  79. image/bmp \
  80. image/svg+xml \
  81. image/vnd.microsoft.icon \
  82. image/x-icon \
  83. text/cache-manifest \
  84. text/css \
  85. text/html \
  86. text/javascript \
  87. text/plain \
  88. text/vcard \
  89. text/vnd.rim.location.xloc \
  90. text/vtt \
  91. text/x-component \
  92. text/x-cross-domain-policy \
  93. text/xml
  94. </IfModule>
  95. <IfModule mod_mime.c>
  96. AddEncoding gzip svgz
  97. </IfModule>
  98. </IfModule>
  99. ### End: Compression ###
  100. ### Begin: Browser caching of resource files ###
  101. # This affects Frontend and Backend and increases performance.
  102. <IfModule mod_expires.c>
  103. ExpiresActive On
  104. ExpiresDefault "access plus 1 month"
  105. ExpiresByType text/css "access plus 1 year"
  106. ExpiresByType application/json "access plus 0 seconds"
  107. ExpiresByType application/ld+json "access plus 0 seconds"
  108. ExpiresByType application/schema+json "access plus 0 seconds"
  109. ExpiresByType application/vnd.geo+json "access plus 0 seconds"
  110. ExpiresByType application/geo+json "access plus 0 seconds"
  111. ExpiresByType application/xml "access plus 0 seconds"
  112. ExpiresByType text/xml "access plus 0 seconds"
  113. ExpiresByType image/vnd.microsoft.icon "access plus 1 week"
  114. ExpiresByType image/x-icon "access plus 1 week"
  115. ExpiresByType text/x-component "access plus 1 month"
  116. ExpiresByType text/html "access plus 0 seconds"
  117. ExpiresByType application/javascript "access plus 1 year"
  118. ExpiresByType application/x-javascript "access plus 1 year"
  119. ExpiresByType text/javascript "access plus 1 year"
  120. ExpiresByType application/manifest+json "access plus 1 week"
  121. ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
  122. ExpiresByType text/cache-manifest "access plus 0 seconds"
  123. ExpiresByType audio/ogg "access plus 1 month"
  124. ExpiresByType image/apng "access plus 1 month"
  125. ExpiresByType image/avif "access plus 1 month"
  126. ExpiresByType image/avif-sequence "access plus 1 month"
  127. ExpiresByType image/bmp "access plus 1 month"
  128. ExpiresByType image/gif "access plus 1 month"
  129. ExpiresByType image/jpeg "access plus 1 month"
  130. ExpiresByType image/jxl "access plus 1 month"
  131. ExpiresByType image/png "access plus 1 month"
  132. ExpiresByType image/svg+xml "access plus 1 month"
  133. ExpiresByType image/webp "access plus 1 month"
  134. ExpiresByType video/mp4 "access plus 1 month"
  135. ExpiresByType video/ogg "access plus 1 month"
  136. ExpiresByType video/webm "access plus 1 month"
  137. ExpiresByType application/atom+xml "access plus 1 hour"
  138. ExpiresByType application/rdf+xml "access plus 1 hour"
  139. ExpiresByType application/rss+xml "access plus 1 hour"
  140. ExpiresByType font/collection "access plus 1 month"
  141. ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  142. ExpiresByType font/eot "access plus 1 month"
  143. ExpiresByType font/opentype "access plus 1 month"
  144. ExpiresByType font/otf "access plus 1 month"
  145. ExpiresByType application/x-font-ttf "access plus 1 month"
  146. ExpiresByType font/ttf "access plus 1 month"
  147. ExpiresByType application/font-woff "access plus 1 month"
  148. ExpiresByType application/x-font-woff "access plus 1 month"
  149. ExpiresByType font/woff "access plus 1 month"
  150. ExpiresByType application/font-woff2 "access plus 1 month"
  151. ExpiresByType font/woff2 "access plus 1 month"
  152. ExpiresByType text/x-cross-domain-policy "access plus 1 week"
  153. </IfModule>
  154. ### End: Browser caching of resource files ###
  155. ### Begin: MIME types ###
  156. # Proper MIME types for all files
  157. <IfModule mod_mime.c>
  158. # Security configuration
  159. RemoveType .html .htm
  160. <FilesMatch ".+\.html?$">
  161. AddType text/html .html .htm
  162. </FilesMatch>
  163. RemoveType .svg .svgz
  164. <FilesMatch ".+\.svgz?$">
  165. AddType image/svg+xml .svg .svgz
  166. </FilesMatch>
  167. # Data interchange
  168. AddType application/atom+xml atom
  169. AddType application/json json map topojson
  170. AddType application/ld+json jsonld
  171. AddType application/rss+xml rss
  172. AddType application/vnd.geo+json geojson
  173. AddType application/xml rdf xml
  174. # JavaScript
  175. AddType application/javascript js
  176. # Manifest files
  177. AddType application/manifest+json webmanifest
  178. AddType application/x-web-app-manifest+json webapp
  179. AddType text/cache-manifest appcache
  180. # Media files
  181. AddType audio/mp4 f4a f4b m4a
  182. AddType audio/ogg oga ogg opus
  183. AddType image/avif avif
  184. AddType image/avif-sequence avifs
  185. AddType image/bmp bmp
  186. AddType image/jxl jxl
  187. AddType image/webp webp
  188. AddType video/mp4 f4v f4p m4v mp4
  189. AddType video/ogg ogv
  190. AddType video/webm webm
  191. AddType video/x-flv flv
  192. AddType image/x-icon cur ico
  193. # Web fonts
  194. AddType font/woff woff
  195. AddType font/woff2 woff2
  196. AddType application/vnd.ms-fontobject eot
  197. AddType font/ttf ttc ttf
  198. AddType font/otf otf
  199. # Other
  200. AddType application/octet-stream safariextz
  201. AddType application/x-bb-appworld bbaw
  202. AddType application/x-chrome-extension crx
  203. AddType application/x-opera-extension oex
  204. AddType application/x-xpinstall xpi
  205. AddType text/vcard vcard vcf
  206. AddType text/vnd.rim.location.xloc xloc
  207. AddType text/vtt vtt
  208. AddType text/x-component htc
  209. </IfModule>
  210. # UTF-8 encoding
  211. AddDefaultCharset utf-8
  212. <IfModule mod_mime.c>
  213. AddCharset utf-8 .atom .css .js .json .manifest .rdf .rss .vtt .webapp .webmanifest .xml
  214. </IfModule>
  215. ### End: MIME types ###
  216. ### Begin: Cross Origin ###
  217. # Send the CORS header for images when browsers request it.
  218. <IfModule mod_setenvif.c>
  219. <IfModule mod_headers.c>
  220. <FilesMatch "\.(avifs?|bmp|cur|gif|ico|jpe?g|png|svgz?|webp)$">
  221. SetEnvIf Origin ":" IS_CORS
  222. Header set Access-Control-Allow-Origin "*" env=IS_CORS
  223. </FilesMatch>
  224. </IfModule>
  225. </IfModule>
  226. # Allow cross-origin access to web fonts.
  227. <IfModule mod_headers.c>
  228. <FilesMatch "\.(eot|otf|tt[cf]|woff2?)$">
  229. Header set Access-Control-Allow-Origin "*"
  230. </FilesMatch>
  231. </IfModule>
  232. ### End: Cross Origin ###
  233. ### Begin: Rewriting and Access ###
  234. <IfModule mod_rewrite.c>
  235. # Enable URL rewriting
  236. RewriteEngine On
  237. # Store the current location in an environment variable CWD to use
  238. # mod_rewrite in .htaccess files without knowing the RewriteBase
  239. RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
  240. RewriteRule ^.*$ - [E=CWD:%2]
  241. # Rules to set ApplicationContext based on hostname
  242. #RewriteCond %{HTTP_HOST} ^dev\.example\.com$
  243. #RewriteRule .? - [E=TYPO3_CONTEXT:Development]
  244. #RewriteCond %{HTTP_HOST} ^staging\.example\.com$
  245. #RewriteRule .? - [E=TYPO3_CONTEXT:Production/Staging]
  246. #RewriteCond %{HTTP_HOST} ^www\.example\.com$
  247. #RewriteRule .? - [E=TYPO3_CONTEXT:Production]
  248. # Rule for versioned static files, configured through:
  249. # - $GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename']
  250. # - $GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename']
  251. # IMPORTANT: This rule has to be the very first RewriteCond in order to work!
  252. RewriteCond %{REQUEST_FILENAME} !-f
  253. RewriteCond %{REQUEST_FILENAME} !-d
  254. RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gz)$ %{ENV:CWD}$1.$3 [L]
  255. # Access block for folders
  256. RewriteRule _(?:recycler|temp)_/ - [F]
  257. RewriteRule fileadmin/templates/.*\.(?:txt|ts)$ - [F]
  258. RewriteRule ^(?:vendor|typo3_src|typo3temp/var) - [F]
  259. RewriteRule (?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/ - [F]
  260. # Block access to all hidden files and directories with the exception of
  261. # the visible content from within the `/.well-known/` hidden directory (RFC 5785).
  262. RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
  263. RewriteCond %{SCRIPT_FILENAME} -d [OR]
  264. RewriteCond %{SCRIPT_FILENAME} -f
  265. RewriteRule (?:^|/)\. - [F]
  266. # Stop rewrite processing, if we are in any other known directory
  267. # NOTE: Add your additional local storages here
  268. RewriteRule ^(?:fileadmin/|typo3conf/|typo3temp/|uploads/) - [L]
  269. # If the file/symlink/directory does not exist but is below /typo3/, redirect to the TYPO3 Backend entry point.
  270. RewriteCond %{REQUEST_FILENAME} !-f
  271. RewriteCond %{REQUEST_FILENAME} !-d
  272. RewriteCond %{REQUEST_FILENAME} !-l
  273. RewriteRule ^typo3/(.*)$ %{ENV:CWD}typo3/index.php [QSA,L]
  274. # If the file/symlink/directory does not exist => Redirect to index.php.
  275. # For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
  276. RewriteCond %{REQUEST_FILENAME} !-f
  277. RewriteCond %{REQUEST_FILENAME} !-d
  278. RewriteCond %{REQUEST_FILENAME} !-l
  279. RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
  280. </IfModule>
  281. # Access block for files
  282. # Apache < 2.3
  283. <IfModule !mod_authz_core.c>
  284. <FilesMatch "(?i:^\.|^#.*#|^(?:ChangeLog|ToDo|Readme|License)(?:\.md|\.txt)?|^composer\.(?:json|lock)|^ext_conf_template\.txt|^ext_typoscript_constants\.txt|^ext_typoscript_setup\.txt|flexform[^.]*\.xml|locallang[^.]*\.(?:xml|xlf)|\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sqlite(?:\..*)?|sw[op]|git.*|rc)|.*~)$">
  285. Order allow,deny
  286. Deny from all
  287. Satisfy All
  288. </FilesMatch>
  289. </IfModule>
  290. # Apache ≥ 2.3
  291. <IfModule mod_authz_core.c>
  292. <If "%{REQUEST_URI} =~ m#(?i:/\.|/\x23.*\x23|/(?:ChangeLog|ToDo|Readme|License)(?:\.md|\.txt)?|/composer\.(?:json|lock)|/ext_conf_template\.txt|/ext_typoscript_constants\.txt|/ext_typoscript_setup\.txt|flexform[^.]*\.xml|locallang[^.]*\.(?:xml|xlf)|\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sqlite(?:\..*)?|sw[op]|git.*|rc)|.*~)$#">
  293. Require all denied
  294. </If>
  295. </IfModule>
  296. # Block access to vcs directories
  297. <IfModule mod_alias.c>
  298. RedirectMatch 404 /\.(?:git|svn|hg)/
  299. </IfModule>
  300. ### End: Rewriting and Access ###
  301. ### Begin: Miscellaneous ###
  302. # 404 error prevention for non-existing redirected folders
  303. Options -MultiViews
  304. # Make sure that directory listings are disabled.
  305. <IfModule mod_autoindex.c>
  306. Options -Indexes
  307. </IfModule>
  308. <IfModule mod_headers.c>
  309. # Force IE to render pages in the highest available mode
  310. Header set X-UA-Compatible "IE=edge"
  311. <FilesMatch "\.(appcache|avifs?|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svgz?|ttf|vcf|webapp|webm|webp|woff2?|xml|xpi)$">
  312. Header unset X-UA-Compatible
  313. </FilesMatch>
  314. # Reducing MIME type security risks
  315. Header set X-Content-Type-Options "nosniff"
  316. </IfModule>
  317. # ETag removal
  318. <IfModule mod_headers.c>
  319. Header unset ETag
  320. </IfModule>
  321. FileETag None
  322. ### End: Miscellaneous ###