-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess
68 lines (54 loc) · 2.39 KB
/
.htaccess
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
RewriteEngine On
# Serve a default PNG image if the requested PNG does not exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^images/.*\.png$ /assets/images/default.png [L]
# redirect '/' to '/home' for external requests only
RewriteCond %{THE_REQUEST} \s/\s [NC]
RewriteRule ^$ /home [L,R=301]
# redirect '/index.php' to '/home' for external requests only
RewriteCond %{THE_REQUEST} \s/index\.php\s [NC]
RewriteRule ^index\.php$ /home [L,R=301]
# Internally rewrite /home, /users, /accounts, to index.php?page=home, index.php?page=users, and index.php?page=accounts
RewriteCond %{REQUEST_URI} ^/(home|users|accounts|info)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /index.php?page=$1 [L]
# Enable caching for certain file types
<IfModule mod_expires.c>
ExpiresActive On
# Cache control for images
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
# Cache control for CSS and JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
# Cache control for fonts
ExpiresByType application/font-woff "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
# Cache control for HTML and XML
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
# Cache control for other file types
ExpiresDefault "access plus 1 week"
</IfModule>
# Set cache control headers
<IfModule mod_headers.c>
<FilesMatch "\.(ico|jpe?g|png|gif|svg|woff2?|ttf|eot)$">
Header set Cache-Control "public"
</FilesMatch>
<FilesMatch "\.(css|js)$">
Header set Cache-Control "public, max-age=2592000"
</FilesMatch>
<FilesMatch "\.(html|xml)$">
Header set Cache-Control "public, max-age=0, must-revalidate"
</FilesMatch>
</IfModule>