| 1 |
mjordaan |
1 |
#################################################################################################
|
|
|
2 |
# START PROCESSWIRE HTACCESS DIRECTIVES
|
|
|
3 |
# @version 3.0
|
|
|
4 |
# @htaccessVersion 301
|
|
|
5 |
#################################################################################################
|
|
|
6 |
#
|
|
|
7 |
# Upgrading htaccess (or index) version 300 to 301
|
|
|
8 |
# -----------------------------------------------------------------------------------------------
|
|
|
9 |
# If you never modified your previous .htaccess file, then you can simply replace it with this
|
|
|
10 |
# one. If you have modified your .htaccess file, then you will want to copy/paste some updates
|
|
|
11 |
# to the old one instead:
|
|
|
12 |
|
|
|
13 |
# If your htaccess/index version is 300, upgrade to this version by replacing all of sections #5
|
|
|
14 |
# and #15 (Access Restrictions). Also take a look at section #9, which you might also consider
|
|
|
15 |
# replacing if using HTTPS, though it is not required. (For instance, HSTS might be worthwhile)
|
|
|
16 |
#
|
|
|
17 |
# Following that, optionally review the rest of the file to see if there are any other changes
|
|
|
18 |
# you also want to apply. Sections tagged "(v301)" are new or have significant changes.
|
|
|
19 |
#
|
|
|
20 |
# When finished, add a line at the top identical to the "htaccessVersion 301" that you see at
|
|
|
21 |
# the top of this file. This tells ProcessWire your .htaccess file is up-to-date.
|
|
|
22 |
#
|
|
|
23 |
# Resolving 500 errors
|
|
|
24 |
# -----------------------------------------------------------------------------------------------
|
|
|
25 |
# Depending on your server, some htaccess rules may not be compatible and result in a 500 error.
|
|
|
26 |
# If you experience this, find all instances of the term "(500)" in this file for suggestions on
|
|
|
27 |
# things you can change to resolve 500 errors.
|
|
|
28 |
#
|
|
|
29 |
# Optional features
|
|
|
30 |
# -----------------------------------------------------------------------------------------------
|
|
|
31 |
# Many of the rules in this .htaccess file are optional and commented out by default. While the
|
|
|
32 |
# defaults are okay for many, you may want to review each section in this .htaccess file for
|
|
|
33 |
# optional rules that you can enable to increase security, speed or best practices. To quickly
|
|
|
34 |
# locate all optional rules, search this file for all instances of "(O)".
|
|
|
35 |
#
|
|
|
36 |
# If using a load balancer
|
|
|
37 |
# -----------------------------------------------------------------------------------------------
|
|
|
38 |
# If using a load balancer (like those available from AWS) some htaccess rules will need to
|
|
|
39 |
# change. Search this file for instances of "(L)" for details.
|
|
|
40 |
#
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
# -----------------------------------------------------------------------------------------------
|
|
|
44 |
# 1. Apache Options
|
|
|
45 |
#
|
|
|
46 |
# Note: If you experience a (500) error, it may indicate your host does not allow setting one or
|
|
|
47 |
# more of these options. First try replacing the +FollowSymLinks with +SymLinksifOwnerMatch.
|
|
|
48 |
# If that does not work, try commenting them all out, then uncommenting one at a time to
|
|
|
49 |
# determine which one is the source of the 500 error.
|
|
|
50 |
# -----------------------------------------------------------------------------------------------
|
|
|
51 |
|
|
|
52 |
# Do not show directory indexes (strongly recommended)
|
|
|
53 |
Options -Indexes
|
|
|
54 |
|
|
|
55 |
# Do not use multiviews (v301)
|
|
|
56 |
Options -MultiViews
|
|
|
57 |
|
|
|
58 |
# Do follow symbolic links
|
|
|
59 |
Options +FollowSymLinks
|
|
|
60 |
# Options +SymLinksifOwnerMatch
|
|
|
61 |
|
|
|
62 |
# Character encoding: Serve text/html or text/plain as UTF-8
|
|
|
63 |
AddDefaultCharset UTF-8
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
# -----------------------------------------------------------------------------------------------
|
|
|
67 |
# 2. ErrorDocument settings: Have ProcessWire handle 404s
|
|
|
68 |
#
|
|
|
69 |
# For options and optimizations (O) see:
|
|
|
70 |
# https://processwire.com/blog/posts/optimizing-404s-in-processwire/
|
|
|
71 |
# -----------------------------------------------------------------------------------------------
|
|
|
72 |
|
|
|
73 |
ErrorDocument 404 /index.php
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
# -----------------------------------------------------------------------------------------------
|
|
|
77 |
# 3. Handle request for missing favicon.ico/robots.txt files (no ending quote for Apache 1.3)
|
|
|
78 |
# -----------------------------------------------------------------------------------------------
|
|
|
79 |
|
|
|
80 |
<Files favicon.ico>
|
|
|
81 |
ErrorDocument 404 "The requested file favicon.ico was not found.
|
|
|
82 |
</Files>
|
|
|
83 |
|
|
|
84 |
<Files robots.txt>
|
|
|
85 |
ErrorDocument 404 "The requested file robots.txt was not found.
|
|
|
86 |
</Files>
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
# -----------------------------------------------------------------------------------------------
|
|
|
90 |
# 4. Protect from XSS with Apache headers
|
|
|
91 |
# -----------------------------------------------------------------------------------------------
|
|
|
92 |
|
|
|
93 |
<IfModule mod_headers.c>
|
|
|
94 |
# prevent site from being loaded in an iframe on another site
|
|
|
95 |
# you will need to remove this one if you want to allow external iframes
|
|
|
96 |
Header always append X-Frame-Options SAMEORIGIN
|
|
|
97 |
|
|
|
98 |
# To prevent cross site scripting (IE8+ proprietary)
|
|
|
99 |
Header set X-XSS-Protection "1; mode=block"
|
|
|
100 |
|
|
|
101 |
# Optionally (O) prevent mime-based attacks via content sniffing (IE+Chrome)
|
|
|
102 |
# Header set X-Content-Type-Options "nosniff"
|
|
|
103 |
</IfModule>
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
# -----------------------------------------------------------------------------------------------
|
|
|
107 |
# 5. Prevent access to various types of files (v301)
|
|
|
108 |
#
|
|
|
109 |
# Note that some of these rules are duplicated by RewriteRules or other .htaccess files, as we
|
|
|
110 |
# try to maintain two layers of protection when/where possible.
|
|
|
111 |
# -----------------------------------------------------------------------------------------------
|
|
|
112 |
|
|
|
113 |
# 5A. Block access to inc, info, info.json/php, module/php, sh, sql and composer files
|
|
|
114 |
# -----------------------------------------------------------------------------------------------
|
|
|
115 |
|
|
|
116 |
<FilesMatch "\.(inc|info|info\.(json|php)|module|module\.php|sh|sql)$|^\..*$|composer\.(json|lock)$">
|
|
|
117 |
<IfModule mod_authz_core.c>
|
|
|
118 |
Require all denied
|
|
|
119 |
</IfModule>
|
|
|
120 |
<IfModule !mod_authz_core.c>
|
|
|
121 |
Order allow,deny
|
|
|
122 |
</IfModule>
|
|
|
123 |
</FilesMatch>
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
# 5B. Block bak, conf, dist, ini, log, orig, sh, sql, swo, swp, ~, and more
|
|
|
127 |
# -----------------------------------------------------------------------------------------------
|
|
|
128 |
|
|
|
129 |
<FilesMatch "(^#.*#|\.(bak|conf|dist|in[ci]|log|orig|sh|sql|sw[op])|~)$">
|
|
|
130 |
<IfModule mod_authz_core.c>
|
|
|
131 |
Require all denied
|
|
|
132 |
</IfModule>
|
|
|
133 |
<IfModule !mod_authz_core.c>
|
|
|
134 |
Order allow,deny
|
|
|
135 |
</IfModule>
|
|
|
136 |
</FilesMatch>
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
# -----------------------------------------------------------------------------------------------
|
|
|
140 |
# 6. Override a few PHP settings that can't be changed at runtime (not required)
|
|
|
141 |
# Note: try commenting out this entire section below if getting Apache (500) errors.
|
|
|
142 |
# -----------------------------------------------------------------------------------------------
|
|
|
143 |
|
|
|
144 |
<IfModule mod_php5.c>
|
|
|
145 |
php_flag magic_quotes_gpc off
|
|
|
146 |
php_flag magic_quotes_sybase off
|
|
|
147 |
php_flag register_globals off
|
|
|
148 |
</IfModule>
|
|
|
149 |
|
|
|
150 |
|
|
|
151 |
# -----------------------------------------------------------------------------------------------
|
|
|
152 |
# 7. Set default directory index files
|
|
|
153 |
# -----------------------------------------------------------------------------------------------
|
|
|
154 |
|
|
|
155 |
DirectoryIndex index.php index.html index.htm
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
# -----------------------------------------------------------------------------------------------
|
|
|
159 |
# 8. Enable Apache mod_rewrite (required)
|
|
|
160 |
# -----------------------------------------------------------------------------------------------
|
|
|
161 |
|
|
|
162 |
<IfModule mod_rewrite.c>
|
|
|
163 |
|
|
|
164 |
RewriteEngine On
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
# 8A. Optionally (O) set a rewrite base if rewrites are not working properly on your server.
|
|
|
168 |
# -----------------------------------------------------------------------------------------------
|
|
|
169 |
# In addition, if your site directory starts with a "~" you will most likely have to use this.
|
|
|
170 |
# https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
|
|
|
171 |
|
|
|
172 |
# Examples of RewriteBase (root and subdirectories):
|
|
|
173 |
# RewriteBase /
|
|
|
174 |
# RewriteBase /pw/
|
|
|
175 |
# RewriteBase /~user/
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
# 8B. Set an environment variable so the installer can detect that mod_rewrite is active.
|
|
|
179 |
# -----------------------------------------------------------------------------------------------
|
|
|
180 |
# Note that some web hosts don't support this. If you get a (500) error, try commenting out this
|
|
|
181 |
# SetEnv line below.
|
|
|
182 |
|
|
|
183 |
<IfModule mod_env.c>
|
|
|
184 |
SetEnv HTTP_MOD_REWRITE On
|
|
|
185 |
</IfModule>
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
# -----------------------------------------------------------------------------------------------
|
|
|
189 |
# 9. Optionally Force HTTPS (O)
|
|
|
190 |
# -----------------------------------------------------------------------------------------------
|
|
|
191 |
# Note that on some web hosts you may need to replace %{HTTPS} with %{ENV:HTTPS} in order
|
|
|
192 |
# for it to work (in sections 9A and 9D below). If on a load balancer or proxy setup, you will
|
|
|
193 |
# likely need to use 9B rather than 9A, and 9E rather than 9D.
|
|
|
194 |
# -----------------------------------------------------------------------------------------------
|
|
|
195 |
|
|
|
196 |
# 9A. To redirect HTTP requests to HTTPS, uncomment the lines below (also see note above):
|
|
|
197 |
# -----------------------------------------------------------------------------------------------
|
|
|
198 |
# RewriteCond %{HTTPS} !=on
|
|
|
199 |
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
# 9B. If using load balancer/AWS or behind proxy, use the following rather than 9A above: (L)
|
|
|
203 |
# -----------------------------------------------------------------------------------------------
|
|
|
204 |
# RewriteCond %{HTTP:X-Forwarded-Proto} =http
|
|
|
205 |
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
# 9C. If using cPanel AutoSSL or Let's Encrypt webroot you may need to MOVE one of the below
|
|
|
209 |
# lines after the first RewriteCond in 9A or 9B to allow certificate validation:
|
|
|
210 |
# -----------------------------------------------------------------------------------------------
|
|
|
211 |
# RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
|
|
|
212 |
# RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[\w-]+$
|
|
|
213 |
# RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
# 9D. Store current scheme in a 'proto' environment variable for later use
|
|
|
217 |
# -----------------------------------------------------------------------------------------------
|
|
|
218 |
RewriteCond %{HTTPS} =on
|
|
|
219 |
RewriteRule ^ - [env=proto:https]
|
|
|
220 |
RewriteCond %{HTTPS} !=on
|
|
|
221 |
RewriteRule ^ - [env=proto:http]
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
# 9E. If using load balancer/AWS or behind proxy, use lines below rather than 9D: (L)
|
|
|
225 |
# -----------------------------------------------------------------------------------------------
|
|
|
226 |
# RewriteCond %{HTTP:X-Forwarded-Proto} =https
|
|
|
227 |
# RewriteRule ^ - [env=proto:https]
|
|
|
228 |
# RewriteCond %{HTTP:X-Forwarded-Proto} =http
|
|
|
229 |
# RewriteRule ^ - [env=proto:http]
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
# 9F. Tell web browsers to only allow access via HSTS: Strict-Transport-Security (O) (v301)
|
|
|
233 |
# -----------------------------------------------------------------------------------------------
|
|
|
234 |
# This forces client-side SSL redirection. Before enabling be absolutely certain you can
|
|
|
235 |
# always serve via HTTPS because it becomes non-revokable for the duration of your max-age.
|
|
|
236 |
# See link below for details and options (note 'max-age=31536000' is 1-year):
|
|
|
237 |
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
|
|
|
238 |
|
|
|
239 |
<IfModule mod_headers.c>
|
|
|
240 |
# Uncomment one (1) line below & adjust as needed to enable Strict-Transport-Security (HSTS):
|
|
|
241 |
# Header always set Strict-Transport-Security "max-age=31536000;"
|
|
|
242 |
# Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains"
|
|
|
243 |
# Header always set Strict-Transport-Security "max-age=31536000; preload"
|
|
|
244 |
# Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
|
|
245 |
</IfModule>
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
# Section 10 intentionally omitted for future use
|
|
|
249 |
|
|
|
250 |
# -----------------------------------------------------------------------------------------------
|
|
|
251 |
# 11. Nuisance blocking/firewall
|
|
|
252 |
# -----------------------------------------------------------------------------------------------
|
|
|
253 |
# None of these are enabled by default, but are here for convenience when the need arises.
|
|
|
254 |
# Review and uncomment as needed. For more complete firewall (and more overhead), the 7G firewall
|
|
|
255 |
# (or latest version) is worth considering, see: https://perishablepress.com/7g-firewall/
|
|
|
256 |
# -----------------------------------------------------------------------------------------------
|
|
|
257 |
|
|
|
258 |
# 11A. Block via IP addresses
|
|
|
259 |
# -----------------------------------------------------------------------------------------------
|
|
|
260 |
# Note that IP addresses here are examples only and should be replaced with actual IPs.
|
|
|
261 |
|
|
|
262 |
# Block single IP address
|
|
|
263 |
# Deny from 111.222.333.444
|
|
|
264 |
|
|
|
265 |
# Block multiple IP addresses
|
|
|
266 |
# Deny from 111.222.333.444 44.33.22.11
|
|
|
267 |
|
|
|
268 |
# Block IP address ranges (999.88.*, 99.88.77.*, 1.2.3.*)
|
|
|
269 |
# Deny from 999.888 99.88.77 1.2.3
|
|
|
270 |
|
|
|
271 |
# 11B. Block via request URI (matches strings anywhere in request URL)
|
|
|
272 |
# -----------------------------------------------------------------------------------------------
|
|
|
273 |
# RewriteCond %{REQUEST_URI} (bad-word|wp-admin|wp-content) [NC]
|
|
|
274 |
# RewriteRule .* - [F,L]
|
|
|
275 |
|
|
|
276 |
# 11B. Block via user agent strings (matches strings anywhere in user-agent)
|
|
|
277 |
# -----------------------------------------------------------------------------------------------
|
|
|
278 |
# RewriteCond %{HTTP_USER_AGENT} (bad-bot|mean-bot) [NC]
|
|
|
279 |
# RewriteRule .* - [F,L]
|
|
|
280 |
|
|
|
281 |
# 11C. Block via remote hosts
|
|
|
282 |
# -----------------------------------------------------------------------------------------------
|
|
|
283 |
# RewriteCond %{REMOTE_HOST} (bad-host|annoying-host) [NC]
|
|
|
284 |
# RewriteRule .* - [F,L]
|
|
|
285 |
|
|
|
286 |
# 11D. Block via HTTP referrer (matches anywhere in referrer URL)
|
|
|
287 |
# -----------------------------------------------------------------------------------------------
|
|
|
288 |
# RewriteCond %{HTTP_REFERER} (bad-referrer|gross-referrer) [NC]
|
|
|
289 |
# RewriteRule .* - [F,L]
|
|
|
290 |
|
|
|
291 |
# 11E. Block unneeded request methods (only if you do not need them)
|
|
|
292 |
# -----------------------------------------------------------------------------------------------
|
|
|
293 |
# RewriteCond %{REQUEST_METHOD} ^(connect|debug|delete|move|put|trace|track) [NC]
|
|
|
294 |
# RewriteRule .* - [F,L]
|
|
|
295 |
|
|
|
296 |
# 11F. Limit file upload size from Apache (i.e. 10240000=10 MB, adjust as needed)
|
|
|
297 |
# -----------------------------------------------------------------------------------------------
|
|
|
298 |
# LimitRequestBody 10240000
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
# -----------------------------------------------------------------------------------------------
|
|
|
303 |
# 12. Access Restrictions: Keep web users out of dirs or files that begin with a period,
|
|
|
304 |
# but let services like Lets Encrypt use the webroot authentication method.
|
|
|
305 |
# -----------------------------------------------------------------------------------------------
|
|
|
306 |
|
|
|
307 |
RewriteRule "(^|/)\.(?!well-known)" - [F]
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
# -----------------------------------------------------------------------------------------------
|
|
|
311 |
# 13. Optional domain redirects (O)
|
|
|
312 |
#
|
|
|
313 |
# Redirect domain.com to www.domain.com redirect (or www to domain.com redirect).
|
|
|
314 |
# If using then uncomment either 13A or 13B, do NOT uncomment both of them or nothing will work.
|
|
|
315 |
# -----------------------------------------------------------------------------------------------
|
|
|
316 |
|
|
|
317 |
# 13A. Redirect domain.com and *.domain.com to www.domain.com (do not combine with 13B):
|
|
|
318 |
# -----------------------------------------------------------------------------------------------
|
|
|
319 |
# RewriteCond %{HTTP_HOST} !^www\. [NC]
|
|
|
320 |
# RewriteCond %{SERVER_ADDR} !=127.0.0.1
|
|
|
321 |
# RewriteCond %{SERVER_ADDR} !=::1
|
|
|
322 |
# RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
# 13B. Redirect www.domain.com to domain.com (do not combine with 13A):
|
|
|
326 |
# -----------------------------------------------------------------------------------------------
|
|
|
327 |
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
|
|
328 |
# RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L]
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
# -----------------------------------------------------------------------------------------------
|
|
|
332 |
# 14. Optionally send URLs with non-ASCII name-format characters to 404 page (optimization).
|
|
|
333 |
#
|
|
|
334 |
# This ensures that ProcessWire does not spend time processing URLs that we know ahead of time
|
|
|
335 |
# are going to result in 404s. Uncomment lines below to enable. (O)
|
|
|
336 |
# -----------------------------------------------------------------------------------------------
|
|
|
337 |
|
|
|
338 |
# RewriteCond %{REQUEST_URI} "[^-_.a-zA-Z0-9/~]"
|
|
|
339 |
# RewriteCond %{REQUEST_FILENAME} !-f
|
|
|
340 |
# RewriteCond %{REQUEST_FILENAME} !-d
|
|
|
341 |
# RewriteRule ^(.*)$ index.php?it=/http404/ [L,QSA]
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
# -----------------------------------------------------------------------------------------------
|
|
|
345 |
# 15. Access Restrictions (v301)
|
|
|
346 |
# -----------------------------------------------------------------------------------------------
|
|
|
347 |
|
|
|
348 |
# 15A. Keep http requests out of specific files and directories
|
|
|
349 |
# -----------------------------------------------------------------------------------------------
|
|
|
350 |
|
|
|
351 |
# Prevent all the following rules from blocking images in site install directories
|
|
|
352 |
RewriteCond %{REQUEST_URI} !(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif|webp|svg)$
|
|
|
353 |
|
|
|
354 |
# Block access to any htaccess files
|
|
|
355 |
RewriteCond %{REQUEST_URI} (^|/)(\.htaccess|htaccess\..*)$ [NC,OR]
|
|
|
356 |
|
|
|
357 |
# Block access to various assets directories
|
|
|
358 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) [NC,OR]
|
|
|
359 |
|
|
|
360 |
# Block access to the /site/install/ directories
|
|
|
361 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/install($|/.*$) [NC,OR]
|
|
|
362 |
|
|
|
363 |
# Block dirs in /site/assets/dirs that start with a hyphen (see config.pagefileSecure)
|
|
|
364 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets.*/-.+/.* [NC,OR]
|
|
|
365 |
|
|
|
366 |
# Block access to /wire/config.php, /site/config.php, /site/config-dev.php, /wire/index.config.php, etc.
|
|
|
367 |
RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php($|/) [NC,OR]
|
|
|
368 |
|
|
|
369 |
# Block access to any PHP-based files in /site/templates-admin/ or /wire/templates-admin/
|
|
|
370 |
RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))($|/) [NC,OR]
|
|
|
371 |
|
|
|
372 |
# Block access to any PHP or markup files in /site/templates/ or /site-*/templates/
|
|
|
373 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))($|/) [NC,OR]
|
|
|
374 |
|
|
|
375 |
# Block access to any files in /site/classes/ or /site-*/classes/
|
|
|
376 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/classes($|/.*) [NC,OR]
|
|
|
377 |
|
|
|
378 |
# Block access to any PHP files within /site/assets/ and further
|
|
|
379 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets($|/|/.*\.ph(p|ps|tml|p[0-9]))($|/) [NC,OR]
|
|
|
380 |
|
|
|
381 |
# Block access to any PHP, module, inc or info files in core or core modules directories
|
|
|
382 |
RewriteCond %{REQUEST_URI} (^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)($|/) [NC,OR]
|
|
|
383 |
|
|
|
384 |
# Block access to any PHP, tpl or info.json files in /site/modules/ or /site-*/modules/
|
|
|
385 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$ [NC,OR]
|
|
|
386 |
|
|
|
387 |
# Block access to any software identifying txt, markdown or textile files
|
|
|
388 |
RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$ [NC,OR]
|
|
|
389 |
|
|
|
390 |
# Block potential arbitrary backup files within site directories for things like config
|
|
|
391 |
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/(config[^/]*/?|[^/]+\.php.*)$ [NC,OR]
|
|
|
392 |
|
|
|
393 |
# Block access throughout to temporary files ending with tilde created by certain editors
|
|
|
394 |
RewriteCond %{REQUEST_URI} \.(html?|inc|json|lock|module|php|py|rb|sh|sql|tpl|tmpl|twig)~$ [NC,OR]
|
|
|
395 |
|
|
|
396 |
# Block access to names of potential backup file extensions within wire or site directories
|
|
|
397 |
RewriteCond %{REQUEST_URI} (^|/)(wire/|site[-/]).+\.(bak|old|sql|sw[op]|(bak|php|sql)[./]+.*)[\d.]*$ [NC,OR]
|
|
|
398 |
|
|
|
399 |
# Block all http access to the default/uninstalled site-default directory
|
|
|
400 |
RewriteCond %{REQUEST_URI} (^|/)site-default/
|
|
|
401 |
|
|
|
402 |
# If any conditions above match, issue a 403 forbidden
|
|
|
403 |
RewriteRule ^.*$ - [F,L]
|
|
|
404 |
|
|
|
405 |
|
|
|
406 |
# 15B. Block archive file types commonly used for backup purposes (O)
|
|
|
407 |
# -----------------------------------------------------------------------------------------------
|
|
|
408 |
# This blocks requests for zip, rar, tar, gz, and tgz files that are sometimes left on servers
|
|
|
409 |
# as backup files, and thus can be problematic for security. This rule blocks those files
|
|
|
410 |
# unless they are located within the /site/assets/files/ directory. This is not enabled by
|
|
|
411 |
# default since there are many legitimate use cases for these files, so uncomment the lines
|
|
|
412 |
# below if you want to enable this.
|
|
|
413 |
|
|
|
414 |
# RewriteCond %{REQUEST_URI} \.(zip|rar|tar|gz|tgz)$ [NC]
|
|
|
415 |
# RewriteCond %{REQUEST_URI} !(^|/)(site|site-[^/]+)/assets/files/\d+/ [NC]
|
|
|
416 |
# RewriteRule ^.*$ - [F,L]
|
|
|
417 |
|
|
|
418 |
|
|
|
419 |
# PW-PAGENAME
|
|
|
420 |
# -----------------------------------------------------------------------------------------------
|
|
|
421 |
# 16A. Ensure that the URL follows the name-format specification required by PW
|
|
|
422 |
# See also directive 16b below, you should choose and use either 16a or 16b.
|
|
|
423 |
# -----------------------------------------------------------------------------------------------
|
|
|
424 |
|
|
|
425 |
RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$"
|
|
|
426 |
|
|
|
427 |
# -----------------------------------------------------------------------------------------------
|
|
|
428 |
# 16B. Alternative name-format specification for UTF8 page name support. (O)
|
|
|
429 |
# If used, comment out section 16a above and uncomment the directive below. If you have updated
|
|
|
430 |
# your $config->pageNameWhitelist make the characters below consistent with that.
|
|
|
431 |
# -----------------------------------------------------------------------------------------------
|
|
|
432 |
|
|
|
433 |
# RewriteCond %{REQUEST_URI} "^/~?[-_./a-zA-Z0-9æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź]*$"
|
|
|
434 |
|
|
|
435 |
# END-PW-PAGENAME
|
|
|
436 |
# -----------------------------------------------------------------------------------------------
|
|
|
437 |
# 17. If the request is for a file or directory that physically exists on the server,
|
|
|
438 |
# then don't give control to ProcessWire, and instead load the file
|
|
|
439 |
# -----------------------------------------------------------------------------------------------
|
|
|
440 |
|
|
|
441 |
RewriteCond %{REQUEST_FILENAME} !-f
|
|
|
442 |
RewriteCond %{REQUEST_FILENAME} !-d
|
|
|
443 |
RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt)
|
|
|
444 |
|
|
|
445 |
# -----------------------------------------------------------------------------------------------
|
|
|
446 |
# 18. Optionally (O) prevent PW from attempting to serve images or anything in /site/assets/.
|
|
|
447 |
# Both of these lines are optional, but can help to reduce server load. However, they
|
|
|
448 |
# are not compatible with the $config->pagefileSecure option (if enabled) and they
|
|
|
449 |
# may produce an Apache 404 rather than your regular 404. You may uncomment the two lines
|
|
|
450 |
# below if you don't need to use the $config->pagefileSecure option. After uncommenting, test
|
|
|
451 |
# a URL like domain.com/site/assets/files/test.jpg to make sure you are getting a 404 and not
|
|
|
452 |
# your homepage. If getting your homepage, then either: do not use this option, or comment out
|
|
|
453 |
# section #2 above that makes ProcessWire the 404 handler.
|
|
|
454 |
# -----------------------------------------------------------------------------------------------
|
|
|
455 |
|
|
|
456 |
# RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|ico|webp|svg)$ [NC]
|
|
|
457 |
# RewriteCond %{REQUEST_FILENAME} !(^|/)site/assets/
|
|
|
458 |
|
|
|
459 |
# -----------------------------------------------------------------------------------------------
|
|
|
460 |
# 19. Pass control to ProcessWire if all the above directives allow us to this point.
|
|
|
461 |
# For regular VirtualHosts (most installs)
|
|
|
462 |
# -----------------------------------------------------------------------------------------------
|
|
|
463 |
|
|
|
464 |
RewriteRule ^(.*)$ index.php?it=$1 [L,QSA]
|
|
|
465 |
|
|
|
466 |
# -----------------------------------------------------------------------------------------------
|
|
|
467 |
# 20. If using VirtualDocumentRoot (500): comment out the one above and use this one instead
|
|
|
468 |
# -----------------------------------------------------------------------------------------------
|
|
|
469 |
|
|
|
470 |
# RewriteRule ^(.*)$ /index.php?it=$1 [L,QSA]
|
|
|
471 |
|
|
|
472 |
</IfModule>
|
|
|
473 |
|
|
|
474 |
#################################################################################################
|
|
|
475 |
# END PROCESSWIRE HTACCESS DIRECTIVES
|
|
|
476 |
#################################################################################################
|
|
|
477 |
|