summaryrefslogtreecommitdiff
path: root/public/.htaccess
blob: d4d7c3d290152a228653eb32fd5dbddc626ccf79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
## Introduce the Server
Header add Origin-Name coder

### Deny access to specific folders

  ## deny all files too
  RedirectMatch 403 ^/app/.*$
  RedirectMatch 403 ^/cache/.*$
  RedirectMatch 403 ^/processed-views/.*$
  
  ## deny folders only
  RedirectMatch 403 ^/css/?$
  RedirectMatch 403 ^/js/?$

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Remove trailing slash
  RewriteRule ^(.*)/$ /$1 [L,R=301,E=limitcache:1]
  # Header always set Cache-Control "max-age=5400" env=limitcache

  # Remove index.php from Application Engine URLs
  # and set 301 Redirects not indefinitely permanent (cache for 1:30h)
  RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
  RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L,QSA,E=limitcache:1]

  # Define some cache-control max-age for environment = limitcache
  # but ExpiresDefault on mod_expires will create a duplicate header_-)
  Header always set Cache-Control "max-age=30" env=limitcache

  # Direct all non-file/directory web requests through the site index file_\\)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
</IfModule>


# <FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
#   <IfModule mod_headers.c>
#     Header set Access-Control-Allow-Origin "*"
#   </IfModule>
# </FilesMatch>


### SERVER SIDE OPTIMIZATIONS

### COMPRESSION

# COMPRESS text-anything output
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/json


### ### CACHE-CONTROL HEADERS

# CACHE-CONTROL IMAGES 100days
<filesMatch ".+\.(jpg|jpeg|png|webp|gif|ico)$">
    Header set Cache-Control "max-age=8640000, public"
</filesMatch>

# CACHE-CONTROL FONTS 200days
<filesMatch "/+\.(ttf|woff|woff2)$">
    Header set Cache-Control "max-age=17280000, public"
</filesMatch>

# CACHE-CONTROL CSS and JS 30days
### <filesMatch ".(css|js)$">
###    Header set Cache-Control "max-age=2592000, public"
### </filesMatch>

### ### EXPIRATION DATES

# EXPIRATION DATE BY TYPE
### <IfModule mod_expires.c>
###     ExpiresActive On
### 
###     # Default directive
###     ExpiresDefault "access plus 0 seconds"
### 
###     # My Fav-icon and Images
###     ExpiresByType image/x-icon "access plus 100 days"
###     ExpiresByType image/gif "access plus 100 days"
###     ExpiresByType image/png "access plus 100 days"
###     ExpiresByType image/jpg "access plus 100 days"
###     ExpiresByType image/jpeg "access plus 100 days"
###     ExpiresByType image/webp "access plus 100 days"
### 
###     # Fonts
###     ExpiresByType font/woff2 "access plus 200 days"
###     ExpiresByType font/ttf "access plus 200 days"
### 
###     # CSS
###     #: ExpiresByType text/css "access plus 1 month"
###     # Javascript
###     #: ExpiresByType application/javascript "access plus 1 year"
### </IfModule>
###
###
# Remove Server's Signature
### ServerSignature Off

# also check:
# TODO: MOVE MOST INTO *.conf file
# + https://stackoverflow.com/questions/10816808/header-expires-not-working
# + https://linuxdigest.com/howto/how-to-set-max-age-in-apache2-cache-control-headers/
# + https://serverfault.com/questions/363692/apache-deflate-ignores-javascript