.htaccess 14 KB

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