×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Apache
Posted by: 1080000000 kmph
Added: May 12, 2020 2:11 PM
Views: 4372
  1. <IfModule mod_rewrite.c>
  2. <IfModule mod_negotiation.c>
  3. Options -MultiViews -Indexes
  4. </IfModule>
  5.  
  6. RewriteEngine On
  7.  
  8. ## HTTPS REDIRECT ##
  9. RewriteCond %{HTTPS} off
  10. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  11. RewriteCond %{HTTP_HOST} !^www\.
  12. RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  13.  
  14. # Handle Authorization Header
  15. RewriteCond %{HTTP:Authorization} .
  16. RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  17.  
  18. # Redirect Trailing Slashes If Not A Folder...
  19. RewriteCond %{REQUEST_FILENAME} !-d
  20. RewriteCond %{REQUEST_URI} (.+)/$
  21. RewriteRule ^ %1 [L,R=301]
  22.  
  23. # Handle Front Controller...
  24. RewriteCond %{REQUEST_FILENAME} !-d
  25. RewriteCond %{REQUEST_FILENAME} !-f
  26. RewriteRule ^ index.php [L]
  27. </IfModule>
  28.  
  29.  
  30. # ----------------------------------------------------------------------
  31. # | Media types                                                        |
  32. # ----------------------------------------------------------------------
  33. <IfModule mod_mime.c>
  34.  
  35. # Data interchange
  36.  
  37. AddType application/atom+xml                        atom
  38. AddType application/json                            json map topojson
  39. AddType application/ld+json                         jsonld
  40. AddType application/rss+xml                         rss
  41. AddType application/geo+json                        geojson
  42. AddType application/rdf+xml                         rdf
  43. AddType application/xml                             xml
  44.  
  45.  
  46. # JavaScript
  47.  
  48. AddType text/javascript                             js mjs
  49.  
  50.  
  51. # Manifest files
  52.  
  53. AddType application/manifest+json                   webmanifest
  54. AddType application/x-web-app-manifest+json         webapp
  55. AddType text/cache-manifest                         appcache
  56.  
  57.  
  58. # Media files
  59.  
  60. AddType audio/mp4                                   f4a f4b m4a
  61. AddType audio/ogg                                   oga ogg opus
  62. AddType image/bmp                                   bmp
  63. AddType image/svg+xml                               svg svgz
  64. AddType image/webp                                  webp
  65. AddType video/mp4                                   f4v f4p m4v mp4
  66. AddType video/ogg                                   ogv
  67. AddType video/webm                                  webm
  68. AddType video/x-flv                                 flv
  69.  
  70. AddType image/x-icon                                cur ico
  71.  
  72.  
  73. # WebAssembly
  74.  
  75. AddType application/wasm                            wasm
  76.  
  77.  
  78. # Web fonts
  79.  
  80. AddType font/woff                                   woff
  81. AddType font/woff2                                  woff2
  82. AddType application/vnd.ms-fontobject               eot
  83. AddType font/ttf                                    ttf
  84. AddType font/collection                             ttc
  85. AddType font/otf                                    otf
  86.  
  87.  
  88. # Other
  89.  
  90. AddType application/octet-stream                    safariextz
  91. AddType application/x-bb-appworld                   bbaw
  92. AddType application/x-chrome-extension              crx
  93. AddType application/x-opera-extension               oex
  94. AddType application/x-xpinstall                     xpi
  95. AddType text/calendar                               ics
  96. AddType text/markdown                               markdown md
  97. AddType text/vcard                                  vcard vcf
  98. AddType text/vnd.rim.location.xloc                  xloc
  99. AddType text/vtt                                    vtt
  100. AddType text/x-component                            htc
  101.  
  102. </IfModule>
  103.  
  104. # ----------------------------------------------------------------------
  105. # | Character encodings                                                |
  106. # ----------------------------------------------------------------------
  107. # Serve all resources labeled as `text/html` or `text/plain`
  108.  
  109. AddDefaultCharset utf-8
  110.  
  111. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  112.  
  113. # Serve the following file types with the media type `charset`
  114. # parameter set to `UTF-8`.
  115.  
  116. <IfModule mod_mime.c>
  117. AddCharset utf-8 .appcache \
  118.              .bbaw \
  119.              .css \
  120.              .htc \
  121.              .ics \
  122.              .js \
  123.              .json \
  124.              .manifest \
  125.              .map \
  126.              .markdown \
  127.              .md \
  128.              .mjs \
  129.              .topojson \
  130.              .vtt \
  131.              .vcard \
  132.              .vcf \
  133.              .webmanifest \
  134.              .xloc
  135. </IfModule>
  136.  
  137. # ######################################################################
  138. # # REWRITES                                                           #
  139. # ######################################################################
  140.  
  141. # ----------------------------------------------------------------------
  142. # | Rewrite engine                                                     |
  143. # ----------------------------------------------------------------------
  144.  
  145. # (1) Turn on the rewrite engine (this is necessary in order for
  146. #     the `RewriteRule` directives to work).
  147. #
  148. #     https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteEngine
  149. #
  150. # (2) Enable the `FollowSymLinks` option if it isn't already.
  151. #
  152. #     https://httpd.apache.org/docs/current/mod/core.html#options
  153. #
  154. # (3) If your web host doesn't allow the `FollowSymlinks` option,
  155. #     you need to comment it out or remove it, and then uncomment
  156. #     the `Options +SymLinksIfOwnerMatch` line (4), but be aware
  157. #     of the performance impact.
  158. #
  159. #     https://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks
  160. #
  161. # (4) Some cloud hosting services will require you set `RewriteBase`.
  162. #
  163. #     https://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-modrewrite-not-working-on-my-site
  164. #     https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
  165. #
  166. # (5) Depending on how your server is set up, you may also need to
  167. #     use the `RewriteOptions` directive to enable some options for
  168. #     the rewrite engine.
  169. #
  170. #     https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions
  171. #
  172. # (6) Set %{ENV:PROTO} variable, to allow rewrites to redirect with the
  173. #     appropriate schema automatically (http or https).
  174.  
  175. #<IfModule mod_rewrite.c>
  176. #
  177. #    # (1)
  178. #    RewriteEngine On
  179. #
  180. #    # (2)
  181. #    Options +FollowSymlinks
  182. #
  183. #    # (3)
  184. #    # Options +SymLinksIfOwnerMatch
  185. #
  186. #    # (4)
  187. #    # RewriteBase /
  188. #
  189. #    # (5)
  190. #    # RewriteOptions <options>
  191. #
  192. #    # (6)
  193. #    RewriteCond %{HTTPS} =on
  194. #    RewriteRule ^ - [env=proto:https]
  195. #    RewriteCond %{HTTPS} !=on
  196. #    RewriteRule ^ - [env=proto:http]
  197. #
  198. #</IfModule>
  199.  
  200. # ----------------------------------------------------------------------
  201. # | Server software information                                        |
  202. # ----------------------------------------------------------------------
  203. ServerSignature Off
  204.  
  205. # ----------------------------------------------------------------------
  206. # | Compression                                                        |
  207. # ----------------------------------------------------------------------
  208. <IfModule mod_deflate.c>
  209. # Force compression for mangled `Accept-Encoding` request headers
  210. <IfModule mod_setenvif.c>
  211. <IfModule mod_headers.c>
  212.     SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  213.     RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  214. </IfModule>
  215. </IfModule>
  216. # Compress all output labeled with one of the following media types.
  217. <IfModule mod_filter.c>
  218. AddOutputFilterByType DEFLATE "application/atom+xml" \
  219.                               "application/javascript" \
  220.                               "application/json" \
  221.                               "application/ld+json" \
  222.                               "application/manifest+json" \
  223.                               "application/rdf+xml" \
  224.                               "application/rss+xml" \
  225.                               "application/schema+json" \
  226.                               "application/geo+json" \
  227.                               "application/vnd.ms-fontobject" \
  228.                               "application/wasm" \
  229.                               "application/x-font-ttf" \
  230.                               "application/x-javascript" \
  231.                               "application/x-web-app-manifest+json" \
  232.                               "application/xhtml+xml" \
  233.                               "application/xml" \
  234.                               "font/eot" \
  235.                               "font/opentype" \
  236.                               "font/otf" \
  237.                               "image/bmp" \
  238.                               "image/svg+xml" \
  239.                               "image/vnd.microsoft.icon" \
  240.                               "text/cache-manifest" \
  241.                               "text/calendar" \
  242.                               "text/css" \
  243.                               "text/html" \
  244.                               "text/javascript" \
  245.                               "text/plain" \
  246.                               "text/markdown" \
  247.                               "text/vcard" \
  248.                               "text/vnd.rim.location.xloc" \
  249.                               "text/vtt" \
  250.                               "text/x-component" \
  251.                               "text/x-cross-domain-policy" \
  252.                               "text/xml"
  253.  
  254. </IfModule>
  255.  
  256. <IfModule mod_mime.c>
  257. AddEncoding gzip              svgz
  258. </IfModule>
  259.  
  260. </IfModule>
  261. # ----------------------------------------------------------------------
  262. # | ETags                                                              |
  263. # ----------------------------------------------------------------------
  264. <IfModule mod_headers.c>
  265. Header unset ETag
  266. </IfModule>
  267.  
  268. FileETag None
  269.  
  270. # ----------------------------------------------------------------------
  271. # | Cache expiration                                                   |
  272. # ----------------------------------------------------------------------
  273. <IfModule mod_expires.c>
  274.  
  275. ExpiresActive on
  276. ExpiresDefault                                      "access plus 1 month"
  277.  
  278. # CSS
  279.  
  280. ExpiresByType text/css                              "access plus 1 year"
  281.  
  282.  
  283. # Data interchange
  284.  
  285. ExpiresByType application/atom+xml                  "access plus 1 hour"
  286. ExpiresByType application/rdf+xml                   "access plus 1 hour"
  287. ExpiresByType application/rss+xml                   "access plus 1 hour"
  288.  
  289. ExpiresByType application/json                      "access plus 0 seconds"
  290. ExpiresByType application/ld+json                   "access plus 0 seconds"
  291. ExpiresByType application/schema+json               "access plus 0 seconds"
  292. ExpiresByType application/geo+json                  "access plus 0 seconds"
  293. ExpiresByType application/xml                       "access plus 0 seconds"
  294. ExpiresByType text/calendar                         "access plus 0 seconds"
  295. ExpiresByType text/xml                              "access plus 0 seconds"
  296.  
  297.  
  298. # Favicon (cannot be renamed!) and cursor images
  299.  
  300. ExpiresByType image/vnd.microsoft.icon              "access plus 1 week"
  301. ExpiresByType image/x-icon                          "access plus 1 week"
  302.  
  303. # HTML
  304.  
  305. ExpiresByType text/html                             "access plus 0 seconds"
  306.  
  307.  
  308. # JavaScript
  309.  
  310. ExpiresByType application/javascript                "access plus 1 year"
  311. ExpiresByType application/x-javascript              "access plus 1 year"
  312. ExpiresByType text/javascript                       "access plus 1 year"
  313.  
  314.  
  315. # Manifest files
  316.  
  317. ExpiresByType application/manifest+json             "access plus 1 week"
  318. ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
  319. ExpiresByType text/cache-manifest                   "access plus 0 seconds"
  320.  
  321.  
  322. # Markdown
  323.  
  324. ExpiresByType text/markdown                         "access plus 0 seconds"
  325.  
  326.  
  327. # Media files
  328.  
  329. ExpiresByType audio/ogg                             "access plus 1 month"
  330. ExpiresByType image/bmp                             "access plus 1 month"
  331. ExpiresByType image/gif                             "access plus 1 month"
  332. ExpiresByType image/jpeg                            "access plus 1 month"
  333. ExpiresByType image/png                             "access plus 1 month"
  334. ExpiresByType image/svg+xml                         "access plus 1 month"
  335. ExpiresByType image/webp                            "access plus 1 month"
  336. ExpiresByType video/mp4                             "access plus 1 month"
  337. ExpiresByType video/ogg                             "access plus 1 month"
  338. ExpiresByType video/webm                            "access plus 1 month"
  339.  
  340.  
  341. # WebAssembly
  342.  
  343. ExpiresByType application/wasm                      "access plus 1 year"
  344.  
  345.  
  346. # Web fonts
  347.  
  348. # Collection
  349. ExpiresByType font/collection                       "access plus 1 month"
  350.  
  351. # Embedded OpenType (EOT)
  352. ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
  353. ExpiresByType font/eot                              "access plus 1 month"
  354.  
  355. # OpenType
  356. ExpiresByType font/opentype                         "access plus 1 month"
  357. ExpiresByType font/otf                              "access plus 1 month"
  358.  
  359. # TrueType
  360. ExpiresByType application/x-font-ttf                "access plus 1 month"
  361. ExpiresByType font/ttf                              "access plus 1 month"
  362.  
  363. # Web Open Font Format (WOFF) 1.0
  364. ExpiresByType application/font-woff                 "access plus 1 month"
  365. ExpiresByType application/x-font-woff               "access plus 1 month"
  366. ExpiresByType font/woff                             "access plus 1 month"
  367.  
  368. # Web Open Font Format (WOFF) 2.0
  369. ExpiresByType application/font-woff2                "access plus 1 month"
  370. ExpiresByType font/woff2                            "access plus 1 month"
  371.  
  372.  
  373. # Other
  374.  
  375. ExpiresByType text/x-cross-domain-policy            "access plus 1 week"
  376.  
  377. </IfModule>
  378.  
  379. # ----------------------------------------------------------------------
  380. # | File concatenation                                                 |
  381. # ----------------------------------------------------------------------
  382.  
  383. # Allow concatenation from within specific files.
  384. #
  385. # e.g.:
  386. #
  387. #   If you have the following lines in a file called, for
  388. #   example, `main.combined.js`:
  389. #
  390. #       <!--#include file="js/jquery.js" -->
  391. #       <!--#include file="js/jquery.timer.js" -->
  392. #
  393. #   Apache will replace those lines with the content of the
  394. #   specified files.
  395.  
  396. # <IfModule mod_include.c>
  397.  
  398. #     <FilesMatch "\.combined\.js$">
  399. #         Options +Includes
  400. #         AddOutputFilterByType INCLUDES application/javascript \
  401. #                                        application/x-javascript \
  402. #                                        text/javascript
  403. #         SetOutputFilter INCLUDES
  404. #     </FilesMatch>
  405.  
  406. #     <FilesMatch "\.combined\.css$">
  407. #         Options +Includes
  408. #         AddOutputFilterByType INCLUDES text/css
  409. #         SetOutputFilter INCLUDES
  410. #     </FilesMatch>
  411.  
  412. # </IfModule>
  413.  
  414. # ----------------------------------------------------------------------
  415. # | Filename-based cache busting                                       |
  416. # ----------------------------------------------------------------------
  417.  
  418. # If you're not using a build process to manage your filename version
  419. # revving, you might want to consider enabling the following directives
  420. # to route all requests such as `/style.12345.css` to `/style.css`.
  421. #
  422. # To understand why this is important and even a better solution than
  423. # using something like `*.css?v231`, please see:
  424. # https://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
  425.  
  426. # <IfModule mod_rewrite.c>
  427. #     RewriteEngine On
  428. #     RewriteCond %{REQUEST_FILENAME} !-f
  429. #     RewriteRule ^(.+)\.(\w+)\.(bmp|css|cur|gif|ico|jpe?g|m?js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
  430. # </IfModule>
  431.  
  432.