-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.htaccess
69 lines (52 loc) · 2.46 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
# MOD_DEFLATE COMPRESSION
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php
# The lines above enable GZIP compression for certain file types, which helps reduce page load times by compressing data before sending it to the browser.
# For incompatible browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# These lines specify how to handle compression for different user agents (browsers).
# Do not cache if these files are already cached
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
# These lines prevent re-compression of already compressed image files to avoid double compression.
# Proxies must serve the correct content
Header append Vary User-Agent env=!dont-vary
# BEGIN Expire headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 7200 seconds"
</IfModule>
# The lines above set expiration headers for various file types, which can help browsers cache static content.
# END Expire headers
# BEGIN Cache-Control Headers
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|gz|ttf|woff2)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
<FilesMatch "\\.(css)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
<FilesMatch "\\.(js)$">
Header set Cache-Control "max-age=31536000, private"
</FilesMatch>
<filesMatch "\\.(html|htm)$">
Header set Cache-Control "max-age=7200, public"
</filesMatch>
# The lines above configure cache control headers for specific file types, instructing browsers to cache them for a certain duration.
# Disable caching for scripts and other dynamic files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>
</IfModule>
# The lines above prevent caching of certain script and dynamic files, ensuring they are fetched fresh from the server each time.
# END Cache-Control Headers
# KILL THEM ETAGS
Header unset ETag
FileETag none
# These lines disable ETags and FileETags, which can reduce unnecessary HTTP requests.
# Forbid AI Crawlers
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (anthropic-ai|AmazonBot|Applebot-Extended|Bytespider|CCBot|ChatGPT-User|Claudebot|Claude-Web|cohere-ai|Diffbot|FacebookBot|Google-Extended|GPTBot|Omgili|Omgilibot|PerplexityBot|YandexAdditionalBot|YouBot) [NC]
RewriteRule ^ – [F]