Advertisement
Guest User

Untitled

a guest
May 15th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.60 KB | None | 0 0
  1. #####
  2. #
  3. # Example .htaccess file for TYPO3 CMS - for use with Apache Webserver
  4. #
  5. # This file includes settings for the following configuration options:
  6. #
  7. # - Compression
  8. # - Caching
  9. # - MIME types
  10. # - Cross Origin requests
  11. # - Rewriting and Access
  12. # - Miscellaneous
  13. # - PHP optimisation
  14. #
  15. # If you want to use it, you have to copy it to the root folder of your TYPO3 installation (if its
  16. # not there already) and rename it to '.htaccess'. To make .htaccess files work, you might need to
  17. # adjust the 'AllowOverride' directive in your Apache configuration file.
  18. #
  19. # IMPORTANT: You may need to change this file depending on your TYPO3 installation!
  20. # Consider adding this file's content to your webserver's configuration directly for speed improvement
  21. #
  22. # Lots of the options are taken from https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess
  23. #
  24. ####
  25.  
  26.  
  27. ### Begin: Compression ###
  28.  
  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.  
  36. AuthType Basic
  37. AuthName "Entwicklung"
  38. AuthUserFile /srv/www/htdocs/www/.htpasswd
  39. Require valid-user
  40.  
  41. <IfModule mod_rewrite.c>
  42. RewriteEngine On
  43. Redirect 301 /test.html /de/fachwissen/aus-und-weiterbildung
  44. </IfModule>
  45.  
  46. <FilesMatch "\.js\.gzip$">
  47. AddType "text/javascript" .gzip
  48. </FilesMatch>
  49. <FilesMatch "\.css\.gzip$">
  50. AddType "text/css" .gzip
  51. </FilesMatch>
  52. AddEncoding gzip .gzip
  53.  
  54. <IfModule mod_deflate.c>
  55. # Force compression for mangled `Accept-Encoding` request headers
  56. <IfModule mod_setenvif.c>
  57. <IfModule mod_headers.c>
  58. SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  59. RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  60. </IfModule>
  61. </IfModule>
  62.  
  63. # Compress all output labeled with one of the following media types.
  64. #
  65. # (!) For Apache versions below version 2.3.7 you don't need to
  66. # enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
  67. # and `</IfModule>` lines as `AddOutputFilterByType` is still in
  68. # the core directives.
  69. #
  70. # https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype
  71.  
  72. <IfModule mod_filter.c>
  73. AddOutputFilterByType DEFLATE application/atom+xml \
  74. application/javascript \
  75. application/json \
  76. application/ld+json \
  77. application/manifest+json \
  78. application/rdf+xml \
  79. application/rss+xml \
  80. application/schema+json \
  81. application/vnd.geo+json \
  82. application/vnd.ms-fontobject \
  83. application/x-font-ttf \
  84. application/x-javascript \
  85. application/x-web-app-manifest+json \
  86. application/xhtml+xml \
  87. application/xml \
  88. font/eot \
  89. font/opentype \
  90. image/bmp \
  91. image/svg+xml \
  92. image/vnd.microsoft.icon \
  93. image/x-icon \
  94. text/cache-manifest \
  95. text/css \
  96. text/html \
  97. text/javascript \
  98. text/plain \
  99. text/vcard \
  100. text/vnd.rim.location.xloc \
  101. text/vtt \
  102. text/x-component \
  103. text/x-cross-domain-policy \
  104. text/xml
  105. </IfModule>
  106.  
  107. <IfModule mod_mime.c>
  108. AddEncoding gzip svgz
  109. </IfModule>
  110. </IfModule>
  111.  
  112. ### End: Compression ###
  113.  
  114.  
  115. ### Begin: MIME types ###
  116.  
  117. # Proper MIME types for all files
  118. <IfModule mod_mime.c>
  119.  
  120. # Data interchange
  121. AddType application/atom+xml atom
  122. AddType application/json json map topojson
  123. AddType application/ld+json jsonld
  124. AddType application/rss+xml rss
  125. AddType application/vnd.geo+json geojson
  126. AddType application/xml rdf xml
  127.  
  128. # JavaScript
  129. AddType application/javascript js
  130.  
  131. # Manifest files
  132. AddType application/manifest+json webmanifest
  133. AddType application/x-web-app-manifest+json webapp
  134. AddType text/cache-manifest appcache
  135.  
  136. # Media files
  137.  
  138. AddType audio/mp4 f4a f4b m4a
  139. AddType audio/ogg oga ogg opus
  140. AddType image/bmp bmp
  141. AddType image/svg+xml svg svgz
  142. AddType image/webp webp
  143. AddType image/jpeg jpg
  144. AddType video/mp4 f4v f4p m4v mp4
  145. AddType video/ogg ogv
  146. AddType video/webm webm
  147. AddType video/x-flv flv
  148. AddType image/x-icon cur ico
  149.  
  150. # Web fonts
  151. AddType application/font-woff woff
  152. AddType application/font-woff2 woff2
  153. AddType application/vnd.ms-fontobject eot
  154. AddType application/x-font-ttf ttc ttf
  155. AddType font/opentype otf
  156.  
  157. # Other
  158. AddType application/octet-stream safariextz
  159. AddType application/x-bb-appworld bbaw
  160. AddType application/x-chrome-extension crx
  161. AddType application/x-opera-extension oex
  162. AddType application/x-xpinstall xpi
  163. AddType text/vcard vcard vcf
  164. AddType text/vnd.rim.location.xloc xloc
  165. AddType text/vtt vtt
  166. AddType text/x-component htc
  167.  
  168. </IfModule>
  169.  
  170. # UTF-8 encoding
  171. AddDefaultCharset utf-8
  172. <IfModule mod_mime.c>
  173. AddCharset utf-8 .atom .css .js .json .manifest .rdf .rss .vtt .webapp .webmanifest .xml
  174. </IfModule>
  175.  
  176. ### End: MIME types ###
  177.  
  178.  
  179.  
  180. ### Begin: Cross Origin ###
  181.  
  182. # Send the CORS header for images when browsers request it.
  183. <IfModule mod_setenvif.c>
  184. <IfModule mod_headers.c>
  185. <FilesMatch "\.(bmp|cur|gif|ico|jpe?g|png|svgz?|webp)$">
  186. SetEnvIf Origin ":" IS_CORS
  187. Header set Access-Control-Allow-Origin "*" env=IS_CORS
  188. </FilesMatch>
  189. </IfModule>
  190. </IfModule>
  191.  
  192. # Allow cross-origin access to web fonts.
  193. <IfModule mod_headers.c>
  194. <FilesMatch "\.(eot|otf|tt[cf]|woff2?)$">
  195. Header set Access-Control-Allow-Origin "*"
  196. </FilesMatch>
  197. </IfModule>
  198.  
  199. ### End: Cross Origin ###
  200.  
  201.  
  202.  
  203. ### Begin: Rewriting and Access ###
  204.  
  205. # You need rewriting, if you use a URL-Rewriting extension (RealURL, CoolUri).
  206.  
  207. <IfModule mod_rewrite.c>
  208.  
  209. # Enable URL rewriting
  210. RewriteEngine On
  211.  
  212. Redirect 301 /services/academy.html /de/fachwissen/aus-und-weiterbildung
  213.  
  214. # Store the current location in an environment variable CWD to use
  215. # mod_rewrite in .htaccess files without knowing the RewriteBase
  216. RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
  217. RewriteRule ^.*$ - [E=CWD:%2]
  218.  
  219. # Rules to set ApplicationContext based on hostname
  220. #RewriteCond %{HTTP_HOST} ^dev\.example\.com$
  221. #RewriteRule .? - [E=TYPO3_CONTEXT:Development]
  222. #RewriteCond %{HTTP_HOST} ^staging\.example\.com$
  223. #RewriteRule .? - [E=TYPO3_CONTEXT:Production/Staging]
  224. #RewriteCond %{HTTP_HOST} ^www\.example\.com$
  225. #RewriteRule .? - [E=TYPO3_CONTEXT:Production]
  226.  
  227. # Rule for versioned static files, configured through:
  228. # - $GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename']
  229. # - $GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename']
  230. # IMPORTANT: This rule has to be the very first RewriteCond in order to work!
  231. RewriteCond %{REQUEST_FILENAME} !-f
  232. RewriteCond %{REQUEST_FILENAME} !-d
  233. RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]
  234.  
  235. # Access block for folders
  236. RewriteRule _(?:recycler|temp)_/ - [F]
  237. RewriteRule fileadmin/templates/.*\.(?:txt|ts)$ - [F]
  238. RewriteRule ^(?:vendor|typo3_src|typo3temp/logs) - [F]
  239. RewriteRule (?:typo3conf/ext|typo3/sysext|typo3/ext)/[^/]+/(?:Configuration|Resources/Private|Tests?|Documentation|docs?)/ - [F]
  240.  
  241. # Block access to all hidden files and directories with the exception of
  242. # the visible content from within the `/.well-known/` hidden directory (RFC 5785).
  243. RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
  244. RewriteCond %{SCRIPT_FILENAME} -d [OR]
  245. RewriteCond %{SCRIPT_FILENAME} -f
  246. RewriteRule (?:^|/)\. - [F]
  247.  
  248. # Stop rewrite processing, if we are in the typo3/ directory or any other known directory
  249. # NOTE: Add your additional local storages here
  250. RewriteRule (?:typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
  251.  
  252.  
  253. RewriteCond %{HTTP:X-Forwarded-Proto} !^https
  254. RewriteRule .* - [E=SEO_PROTOCOL:http]
  255. RewriteCond %{HTTP:X-Forwarded-Proto} ^https
  256. RewriteRule .* - [E=SEO_PROTOCOL:https]
  257.  
  258. RewriteCond %{REQUEST_FILENAME} !-f
  259. RewriteCond %{REQUEST_URI} !^/robots.txt$
  260. RewriteCond %{REQUEST_URI} !^/typo3(.*)$
  261.  
  262.  
  263. ### Begin: Static File Cache (preparation) ####
  264.  
  265. # Document root configuration
  266. RewriteRule .* - [E=SFC_ROOT:%{DOCUMENT_ROOT}]
  267. # RewriteRule .* - [E=SFC_ROOT:%{DOCUMENT_ROOT}/t3site] # Example if your installation is installed in a directory
  268.  
  269. # Cleanup URI
  270. RewriteCond %{REQUEST_URI} ^.*$
  271. RewriteRule .* - [E=SFC_URI:/%{REQUEST_URI}]
  272. RewriteCond %{REQUEST_URI} ^/.*$
  273. RewriteRule .* - [E=SFC_URI:%{REQUEST_URI}]
  274. RewriteCond %{REQUEST_URI} ^/?$
  275. RewriteRule .* - [E=SFC_URI:/]
  276.  
  277. # Get scheme/protocol
  278. RewriteCond %{SERVER_PORT} ^443$
  279. RewriteRule .* - [E=SFC_PROTOCOL:https]
  280. RewriteCond %{SERVER_PORT} !^443$
  281. RewriteRule .* - [E=SFC_PROTOCOL:http]
  282.  
  283. # Set gzip extension into an environment variable if the visitors browser can handle gzipped content.
  284. RewriteCond %{HTTP:Accept-Encoding} gzip [NC]
  285. RewriteRule .* - [E=SFC_GZIP:.gz]
  286. RewriteRule .* - [E=SFC_GZIP:] # Add this line, to disable the gzip redirect
  287.  
  288. # Check if the requested file exists in the cache, otherwise default to index.html that
  289. # set in an environment variable that is used later on
  290. RewriteCond %{ENV:SFC_ROOT}/typo3temp/tx_ncstaticfilecache/%{ENV:SFC_PROTOCOL}/%{HTTP_HOST}%{ENV:SFC_URI} !-f
  291. RewriteRule .* - [E=SFC_FILE:/index.html]
  292.  
  293. ### Begin: Static File Cache (main) ####
  294.  
  295. # We only redirect URI's without query strings
  296. RewriteCond %{QUERY_STRING} ^$
  297.  
  298. # It only makes sense to do the other checks if a static file actually exists.
  299. RewriteCond %{ENV:SFC_ROOT}/typo3temp/tx_ncstaticfilecache/%{ENV:SFC_PROTOCOL}/%{HTTP_HOST}%{ENV:SFC_URI}%{ENV:SFC_FILE}%{ENV:SFC_GZIP} -f
  300.  
  301. # NO frontend user is logged in. Logged in frontend users may see different
  302. # information than anonymous users. But the anonymous version is cached. So
  303. # don't show the anonymous version to logged in frontend users.
  304. RewriteCond %{HTTP_COOKIE} !nc_staticfilecache [NC]
  305.  
  306. # Uncomment the following line if you use MnoGoSearch
  307. #RewriteCond %{HTTP:X-TYPO3-mnogosearch} ^$
  308.  
  309. # We only redirect GET requests
  310. RewriteCond %{REQUEST_METHOD} GET
  311.  
  312. # NO backend user is logged in. Please note that the be_typo_user cookie expires at the end of the browser session.
  313. # If you have logged out of the TYPO3 backend and are expecting to see cached pages but don't.
  314. # Please close this browser session first or remove the cookie manually or use another browser to hit your frontend.
  315. RewriteCond %{HTTP_COOKIE} !be_typo_user [NC]
  316.  
  317. # Rewrite the request to the static file.
  318. RewriteRule .* typo3temp/tx_ncstaticfilecache/%{ENV:SFC_PROTOCOL}/%{HTTP_HOST}%{ENV:SFC_URI}%{ENV:SFC_FILE}%{ENV:SFC_GZIP} [L]
  319.  
  320. # Do not allow direct call the cache entries
  321. RewriteCond %{ENV:SFC_URI} ^/typo3temp/tx_ncstaticfilecache/.*
  322. RewriteCond %{ENV:REDIRECT_STATUS} ^$
  323. RewriteRule .* - [F,L]
  324.  
  325. ### Begin: Static File Cache (options) ####
  326.  
  327. # Set proper content type and encoding for gzipped html.
  328. <FilesMatch "\.gz">
  329. <IfModule mod_headers.c>
  330. Header set Content-Encoding gzip
  331. </IfModule>
  332. </FilesMatch>
  333.  
  334. # if there are same problems with ForceType, please try the AddType alternative
  335. # Set proper content type gzipped html
  336. <FilesMatch "\.html\.gz">
  337. ForceType text/html
  338. # AddType "text/html" .gz
  339. </FilesMatch>
  340. <FilesMatch "\.xml\.gz">
  341. ForceType text/xml
  342. # AddType "text/xml" .gz
  343. </FilesMatch>
  344. <FilesMatch "\.rss\.gz">
  345. ForceType text/xml
  346. # AddType "text/xml" .gz
  347. </FilesMatch>
  348.  
  349. ## For SEO, set "de" as default or accept other language
  350. RewriteCond %{REQUEST_FILENAME} !-f
  351. RewriteCond %{REQUEST_URI} !^/robots.txt$
  352. RewriteCond %{REQUEST_URI} !^/de/(.*)$
  353. RewriteCond %{REQUEST_URI} !^/fr/(.*)$
  354. RewriteCond %{REQUEST_URI} !^/en/(.*)$
  355. RewriteCond %{REQUEST_URI} !^/de(.*)$
  356. RewriteCond %{REQUEST_URI} !^/fr(.*)$
  357. RewriteCond %{REQUEST_URI} !^/en(.*)$
  358. RewriteCond %{REQUEST_URI} !^/typo3(.*)$
  359. RewriteRule ^(.*)$ /de/$1 [L,R=301]
  360. ## end
  361.  
  362. # If the file/symlink/directory does not exist => Redirect to index.php.
  363. # For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
  364. RewriteCond %{REQUEST_FILENAME} !-f
  365. RewriteCond %{REQUEST_FILENAME} !-d
  366. RewriteCond %{REQUEST_FILENAME} !-l
  367. RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
  368.  
  369. </IfModule>
  370.  
  371. # Access block for files
  372. <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|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sw[op]|git.*)|.*(?:~|rc))$">
  373. # Apache < 2.3
  374. <IfModule !mod_authz_core.c>
  375. Order allow,deny
  376. Deny from all
  377. Satisfy All
  378. </IfModule>
  379.  
  380. # Apache ≥ 2.3
  381. <IfModule mod_authz_core.c>
  382. Require all denied
  383. </IfModule>
  384. </FilesMatch>
  385.  
  386. # Block access to vcs directories
  387. <IfModule mod_alias.c>
  388. RedirectMatch 404 /\.(?:git|svn|hg)/
  389. </IfModule>
  390.  
  391. ### End: Rewriting and Access ###
  392.  
  393.  
  394.  
  395. ### Begin: Miscellaneous ###
  396.  
  397. # 404 error prevention for non-existing redirected folders
  398. Options -MultiViews
  399.  
  400. # Make sure that directory listings are disabled.
  401. <IfModule mod_autoindex.c>
  402. Options -Indexes
  403. </IfModule>
  404.  
  405. <IfModule mod_headers.c>
  406. # Force IE to render pages in the highest available mode
  407. Header set X-UA-Compatible "IE=edge"
  408. <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)$">
  409. Header unset X-UA-Compatible
  410. </FilesMatch>
  411.  
  412. # Reducing MIME type security risks
  413. Header set X-Content-Type-Options "nosniff"
  414. </IfModule>
  415.  
  416. # ETag removal
  417. <IfModule mod_headers.c>
  418. Header unset ETag
  419. </IfModule>
  420. FileETag None
  421.  
  422. ### End: Miscellaneous ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement