Repository navigation
Expand file tree
/
Copy path.htaccess
More file actions
119 lines (118 loc) · 5.42 KB
/
Copy path.htaccess
File metadata and controls
119 lines (118 loc) · 5.42 KB
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
117
118
119
# BEGIN HAXcms managed
# HAXcms rewrites everything between the BEGIN and END markers on rebuild.
# Put site-specific rules outside the markers; they are kept.
# Protect files and directories from prying eyes.
<FilesMatch "\.(make|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Set the default handler.
DirectoryIndex index.php index.html
# Override PHP settings that cannot be changed at runtime. See
<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag magic_quotes_sybase off
php_flag register_globals off
php_flag session.auto_start off
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
</IfModule>
<IfModule mod_mime.c>
<Files "api-catalog">
ForceType application/linkset+json
</Files>
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Security (SEC-DEPLOY): never serve anything inside a dot-directory or dotfile
# over HTTP (this site's .git history, .github, ...). Repeated here because
# "RewriteEngine on" in this file stops the HAXcms root .htaccess rewrite
# rules from applying inside the site directory, and the site may also be
# served from its own vhost/docroot. .git stays readable on the server for
# HAXcms tooling and site zip downloads. /.well-known/ stays reachable.
RewriteRule "(^|/)\.(?!well-known(/|$))" - [F]
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# Make sure Authorization HTTP header is available to PHP
# even when running as CGI or FastCGI.
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Pass all requests not referring directly to files in the filesystem to
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ . [L]
# Rules to correctly serve gzip compressed CSS and JS files.
# Requires both mod_rewrite and mod_headers to be enabled.
<IfModule mod_headers.c>
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
# Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header set Content-Encoding gzip
# Force proxies to cache gzipped & non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
</IfModule>
# Add headers to all responses.
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
Header always set X-Content-Type-Options nosniff
<Files "api-catalog">
Header set Content-Type "application/linkset+json; profile=\"https://www.rfc-editor.org/info/rfc9727\""
</Files>
</IfModule>
# Tag machine-readable managed/generated files as UTF-8 so clients don't
# guess an encoding (fixes mojibake in llms.txt, robots.txt, site.json,
# page .md/.yaml/.xml sidecars, etc). All of these are written by
# HAXcms tooling, which always emits UTF-8.
<IfModule mod_mime.c>
AddCharset UTF-8 .txt .md .json .yaml .yml .xml
</IfModule>
# Page bodies (pages/<id>/index.html) are fragments the site shell loads.
# Crawlers may fetch them to render a page, but they stay out of search
# results; robots.txt no longer blocks them, so this header does that job.
<IfModule mod_headers.c>
<If "%{REQUEST_URI} =~ m#(^|/)pages/[^/]+/index\.html$#">
Header set X-Robots-Tag "noindex"
</If>
</IfModule>
# END HAXcms managed
# Browser cache policy, the same as haxcms-nodejs. Build modules
# (build/es6/...) are only replaced by a HAXcms upgrade, but their paths
# carry no version, so they are reused for at most an hour: anything longer
# lets a page mix old and new modules after an upgrade. Everything else
# (site.json, page content, the component registry, theme and custom build
# files, uploads) is revalidated on every use, so an edit or upgrade shows at
# once; ETag/Last-Modified make that a 304. setifempty: responses that PHP
# answers keep their own Cache-Control (no-store on the system API).
<IfModule mod_headers.c>
<If "%{REQUEST_URI} =~ m#(^|/)build/# && %{REQUEST_URI} !~ m#(^|/)(files|custom/build)/# && %{REQUEST_URI} !~ m#wc-registry(-graph)?\.json$#">
Header setifempty Cache-Control "public, max-age=3600"
</If>
<Else>
Header setifempty Cache-Control "public, max-age=0"
</Else>
</IfModule>