-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess
84 lines (67 loc) · 2.27 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
AddDefaultCharset UTF-8
# Limit file uploads to 100K
LimitRequestBody 102400
# Preserve bandwidth for PHP enabled servers
<ifmodule mod_php4.c>
php_value zlib.output_compression 16386
</ifmodule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Fuck the www prefix!
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %{REQUEST_SCHEME}://%1%{REQUEST_URI} [R=307,L]
# Block access to all hidden files and directories except for the
# visible content from within the `/.well-known/` hidden directory.
RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
# Block access to the data directory
RewriteRule ^data/?$ - [F,L]
# Fancy URLs (without .php suffix) for endpoints.
RewriteCond %{REQUEST_URI} ^/endpoint/(.+)$
RewriteCond %{DOCUMENT_ROOT}/endpoint/%1.php -f
RewriteRule ^(.+)$ /endpoint/$1.php [L]
# Block direct access for all other PHP files.
RewriteCond %{REQUEST_FILENAME} \.php$ [NC]
RewriteRule ^ - [F]
# Feeds
RewriteRule ^rss\.xml$ /feed/rss.php [L]
RewriteRule ^atom\.xml$ /feed/atom.php [L]
RewriteRule ^feed\.json$ /feed/json.php [L]
# PHP-based routing (yippie!!)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# Preserve bandwidth for PHP enabled servers
<IfModule mod_php4.c>
php_value zlib.output_compression 16386
</IfModule>
# Follow symbolic links
Options +FollowSymLinks
# GZip compression
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
# Caching
<IfModule mod_headers.c>
# Cache static assets and images ~forever (max value for max age)
<FilesMatch "\.(jpg|jpeg|png|webp|gif|svg|woff|woff2)$">
Header set Cache-Control "max-age=31536000, immutable"
</FilesMatch>
# Cache SS and JavaScript files for one week
<FilesMatch "\.(js|css)$">
Header set Cache-Control "max-age=604800, stale-while-revalidate"
</FilesMatch>
# Cache content for a day
<FilesMatch "\.(html|pdf|txt)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
# Explicitly disable caching for scripts and other dynamic files
<FilesMatch "\.(pl|cgi|spl|scgi|fcgi|php)$">
Header set Cache-Control "no-cache"
Header unset Expires
</FilesMatch>
</IfModule>