-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
707 lines (627 loc) · 33.6 KB
/
index.html
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/style2.css">
<meta http-equiv="Content-Security-Policy" content="block-all-mixed-content">
<title>.htaccesss Cheat Sheet</title>
<meta name="description" content=".htaccesss File Cheat Sheet - A reference for Increased Security.">
<link rel="stylesheet" href="css/style.css">
<link rel="apple-touch-icon" sizes="180x180" href="img/images.png">
<link rel="icon" type="image/png" sizes="32x32" href="img/images.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/images.png">
<link rel="shortcut icon" href="img/favicon.ico">
<meta name="theme-color" content="#ffffff">
<meta property="og:url" content="https://github.com/stefanpejcic/htaccess">
<meta property="og:type" content="website">
<meta property="og:title" content=".htaccesss Cheat Sheet">
<meta property="og:image" content="https://github.com/stefanpejcic/htaccess/img/images.png">
<meta property="og:description" content=".htaccesss Cheat Sheet - A reference for .htaccesss goodness.">
<meta property="og:site_name" content=".htaccesss Cheat Sheet">
<meta property="og:locale" content="en_GB">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@StefanPejcic>
<meta name="twitter:creator" content="@StefanPejcic">
<meta name="twitter:url" content="https://github.com/stefanpejcic/htaccesss">
<meta name="twitter:title" content=".htaccesss Cheat Sheet">
<meta name="twitter:description" content=".htaccesss Cheat Sheet - A reference for CF goodness.">
<meta name="twitter:image" content="https://github.com/stefanpejcic/htaccesss/img/images.png">
<meta itemprop="name" content=".htaccesss Cheat Sheet">
<meta itemprop="description" content=".htaccesss Cheat Sheet - A reference for CF goodness.">
<meta itemprop="image" content="https://github.com/stefanpejcic/htaccesss/img/img/images.png">
<meta name="robots" content="index,follow,noodp">
<meta name="googlebot" content="index,follow">
<meta name="format-detection" content="telephone=no">
<link href="https://fonts.googleapis.com/css?family=Muli:400,600,700" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="bgBlob bgBlob--1"></div>
<div class="bgBlob bgBlob--2"></div>
<div class="svgcompile"><svg xmlns="http://www.w3.org/2000/svg"><symbol viewBox="0 0 14 11.9" id="github"><title>github</title> <g> <g> <path d="M9.4,6.9c0.3,0,0.5,0.1,0.7,0.4c0.2,0.3,0.3,0.6,0.3,1c0,0.4-0.1,0.7-0.3,1C9.9,9.5,9.7,9.6,9.4,9.6
c-0.3,0-0.5-0.1-0.7-0.4C8.5,9,8.4,8.7,8.4,8.3c0-0.4,0.1-0.7,0.3-1C8.9,7,9.2,6.9,9.4,6.9 M12.9,3.3c0.7,0.8,1.1,1.8,1.1,3
c0,0.7-0.1,1.4-0.3,2c-0.2,0.6-0.4,1.1-0.7,1.5c-0.3,0.4-0.6,0.7-1,1c-0.4,0.3-0.7,0.5-1.1,0.6c-0.3,0.1-0.7,0.2-1.1,0.3
c-0.4,0.1-0.7,0.1-0.9,0.1c-0.2,0-0.4,0-0.7,0c-0.1,0-0.2,0-0.5,0c-0.3,0-0.6,0-0.8,0s-0.5,0-0.8,0c-0.3,0-0.5,0-0.5,0
c-0.2,0-0.5,0-0.7,0c-0.2,0-0.5-0.1-0.9-0.1c-0.4-0.1-0.8-0.2-1.1-0.3c-0.3-0.1-0.7-0.3-1.1-0.6c-0.4-0.3-0.7-0.6-1-1
C0.7,9.4,0.4,8.9,0.3,8.3C0.1,7.7,0,7,0,6.3c0-1.2,0.4-2.1,1.1-3C1,3.3,1,2.9,1.1,2.1C1.2,1.4,1.3,0.7,1.6,0
c0.9,0.1,2.1,0.6,3.5,1.6C5.5,1.5,6.2,1.4,7,1.4c0.9,0,1.5,0.1,1.9,0.2c0.6-0.4,1.2-0.8,1.8-1c0.6-0.3,1-0.4,1.3-0.5L12.4,0
c0.3,0.6,0.4,1.4,0.5,2.1C13,2.9,13,3.3,12.9,3.3 M7,11.2c1.7,0,3-0.2,3.8-0.6c0.9-0.4,1.3-1.2,1.3-2.5c0-0.7-0.3-1.3-0.8-1.8
c-0.3-0.3-0.6-0.4-1-0.5c-0.4-0.1-0.9-0.1-1.7,0C7.8,5.8,7.3,5.8,7,5.8c-0.4,0-0.8,0-1.3-0.1c-0.5,0-0.9-0.1-1.2-0.1
c-0.3,0-0.6,0-1,0.1C3.2,5.9,2.9,6,2.7,6.2C2.2,6.7,1.9,7.3,1.9,8.1c0,1.3,0.4,2.1,1.3,2.5C4,11,5.3,11.2,7,11.2L7,11.2 M4.6,6.9
c0.3,0,0.5,0.1,0.7,0.4c0.2,0.3,0.3,0.6,0.3,1c0,0.4-0.1,0.7-0.3,1C5.1,9.5,4.9,9.6,4.6,9.6c-0.3,0-0.5-0.1-0.7-0.4
C3.7,9,3.6,8.7,3.6,8.3c0-0.4,0.1-0.7,0.3-1C4.1,7,4.3,6.9,4.6,6.9"/> </g> </g> </symbol></svg></div>
<header class="container">
<div class="row">
<div class="col">
<h5 class="sidebar__title">.htaccesss</h5>
</div>
<div class="col">
<div class="icon">
<div class="top"></div>
<div class="mid"></div>
<div class="bot"></div>
</div>
</div>
</div>
</header>
<div class="sidebar">
<h5 class="sidebar__title">.htaccesss</h5>
<nav class="sidebar__nav">
<ul>
<li><a href="#Rewrite">Redirection</a></li>
<li><a href="#Security">Security</a></li>
<li><a href="#Performance">Performance</a></li>
<li><a href="#Miscellaneous">Miscellaneous</a></li>
</ul>
</nav>
<div class="social">
<p style="margin-bottom:10px;">join the dark side</p>
<div class="switch" style="margin-bottom:100px;">
<input class="switch__input" type="checkbox" id="themeSwitch">
<label aria-hidden="true" class="switch__label" for="themeSwitch">On</label>
<div aria-hidden="true" class="switch__marker"></div>
</div>
<a target="_blank" href="https://github.com/stefanpejcic/.htaccess"><svg viewBox="0 0 14 11.9"><use xlink:href="#github"/></svg> Contribute</a>
</div>
</div>
<div class="content">
<h1 class="content__title">.htaccess Cheat Sheet</h1>
<h3 class="content__subTitle">All the important Apache .htaccess web server rules and config options</h3>
<div class="container">
<a class="bmc-button" target="_blank" href="https://www.buymeacoffee.com/stefanpejcic"><img src="https://www.buymeacoffee.com/assets/img/BMC-btn-logo.svg" alt="Buy me a cup of coffee"><span style="margin-left:5px">Donate a Cup of Coffee ❤️</span></a>
</div>
<section class="container section" id="Rewrite">
<h3 class="section__title">Rewrite and Redirection</h3>
<p class="section__title" style="margin-bottom: 10px; margin-top: -15px;">(Note: It is assumed that you have `mod_rewrite` installed and enabled. The first line should be 'RewriteEngine on' to enable this)</p>
<div class="row">
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Serve All Requests With One PHP File</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php [NC,L,QSA]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force www with .htaccess</p>
<pre>RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force www in a Generic Way with .htaccess</p>
<pre>RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force non-www with .htaccess</p>
<pre>RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force non-www in a Generic Way with .htaccess</p>
<pre>RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{HTTPS}s ^on(s)|off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force HTTPS with .htaccess</p>
<pre>RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force HTTPS Behind a Proxy with .htaccess</p>
<pre>RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force Trailing Slash with .htaccess</p>
<pre>RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Remove Trailing Slash with .htaccess</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Redirect a Single Page with .htaccess</p>
<pre>Redirect 301 /oldpage.html https://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html https://www.yoursite.com/folder/</pre>
</code>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Alias a Single Directory with .htaccess</p>
<pre>RewriteEngine On
RewriteRule ^source-directory/(.*) target-directory/$1</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Alias Paths To Script with .htaccess</p>
<pre>RewriteEngine On
RewriteRule ^$ index.fcgi/ [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Redirect an Entire Site with .htaccess</p>
<pre>Redirect 301 / https://newsite.com/</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Alias "Clean" URLs with .htaccess</p>
<pre>RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]</pre>
</div>
</div>
</div>
</div>
</section>
<section class="container section" id="Security">
<h3 class="section__title">Security Rules</h3>
<p class="section__title" style="margin-bottom: 10px; margin-top: -15px;"></p>
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Deny All Access with .htaccess</p>
<pre># Require all denied</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Only allow certain IPs with .htaccess</p>
<pre># Require all denied
# Require ip xxx.xxx.xxx.xxx</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Block IP Address with .htaccesss</p>
<pre># Require all granted
# Require not ip xxx.xxx.xxx.xxx
# Require not ip xxx.xxx.xxx.xxy</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Allow access only from LAN with .htaccess</p>
<pre>order deny,allow
deny from all
allow from 192.168.0.0/24</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Deny Access To Certain User Agents with .htaccess</p>
<pre>RewriteCond %{HTTP_USER_AGENT} ^User\ Agent\ 1 [OR]
RewriteCond %{HTTP_USER_AGENT} ^Another\ Bot\ You\ Want\ To\ Block [OR]
RewriteCond %{HTTP_USER_AGENT} ^Another\ UA
RewriteRule ^.* - [F,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Deny Access to Hidden Files and Directories with .htaccess</p>
<pre><files your-file-name.txt>
order allow,deny
deny from all
</files></pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Deny Access to Backup and Source Files with .htaccess</p>
<pre><FilesMatch "(\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)|~)$">
## Apache 2.2
Order allow,deny
Deny from all
Satisfy All
## Apache 2.4
# Require all denied
</FilesMatch></pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Disable Directory Browsing with .htaccess</p>
<pre>Options All -Indexes</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Enable Directory Listings with .htaccess</p>
<pre>Options All +Indexes</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Disable Listing Of Certain Filetypes with .htaccess</p>
<pre>IndexIgnore *.zip *.mp4 *.pdf</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Disable Image Hotlinking with .htaccess</p>
<pre>RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Redirect hotlinkers and show a different image with .htaccess</p>
<pre>RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://(www\.)?your-website.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ https://www.your-website.com/do-not-hotlink-our-content.jpg [R,L]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Deny Access from certain referrers with .htaccess</p>
<pre>RewriteCond %{HTTP_REFERER} block-this-referer\.com [NC,OR]
RewriteCond %{HTTP_REFERER} and-block-traffic-that-this-site-sends\.com [NC]
RewriteRule .* - [F]</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Password Protect a Directory with .htaccess</p>
<pre>AuthType Basic
AuthName "Password Protected Dir Title"
AuthUserFile /home/hidden/directory/here/.htpasswd
Require valid-user</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Password Protect a File or Several Files with .htaccess</p>
<pre>AuthName "Password Protected Directory Title"
AuthType Basic
AuthUserFile /home/hidden/directory/here/.htpasswd
<Files "/a-private-file.txt">
Require valid-user
</Files>
<FilesMatch ^((one|two|three)-rings?\.o)$>
Require valid-user
</FilesMatch></pre>
</div>
</div>
</div>
</section>
<section class="container section" id="Performance">
<h3 class="section__title">Performance Rules</h3>
<p class="section__title" style="margin-bottom: 10px; margin-top: -15px;"></p>
<div class="row">
<div class="col-md-6 col-lg-12">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Compress Text Files (gzip/deflate output) with .htaccess</p>
<pre><IfModule mod_deflate.c>
# Force compression for mangled headers.
# https://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
# and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
# as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule></pre>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Turn eTags Off with .htaccess</p>
<pre><IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Limit Upload File Size with .htaccess</p>
<pre>LimitRequestBody 1048576</pre>
</div>
</div>
</div>
</div>
</section>
<section class="container section" id="Miscellaneous">
<h3 class="section__title">Miscellaneous Rules</h3>
<p class="section__title" style="margin-bottom: 10px; margin-top: -15px;"></p>
<div class="row">
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Server Variables for mod_re足write with .htaccess</p>
<pre>%{API_VERSION}
%{DOCUMENT_ROOT}
%{HTTP_ACCEPT}
%{HTTP_COOKIE}
%{HTTP_FORWARDED}
%{HTTP_HOST}
%{HTTP_PROXY_CONNECTION}
%{HTTP_REFERER}
%{HTTP_USER_AGENT}
%{HTTPS}
%{IS_SUBREQ}
%{REQUEST_FILENAME}
%{REQUEST_URI}
%{SERVER_ADDR}
%{SERVER_ADMIN}
%{SERVER_NAME}
%{SERVER_PORT}
%{SERVER_PROTOCOL}
%{SERVER_SOFTWARE}
%{THE_REQUEST}</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Set PHP Variables with .htaccess</p>
<pre>php_value <key> <val></pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Custom Error Pages with .htaccess</p>
<pre>ErrorDocument 500 "Houston, we have a problem."
ErrorDocument 401 https://error.yourdomain.com/mordor.html
ErrorDocument 404 /errors/halflife3.html</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Redirect users to a maintenance page in .htaccess</p>
<pre>ErrorDocument 403 YourMaintenancePageFilenameOrFullUrlUrl.html
Order deny,allow
Deny from all
Allow from 555.555.555.555</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Force Downloading with .htaccess</p>
<pre><Files *.md>
ForceType application/octet-stream
Header set Content-Disposition attachment
</Files></pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Disable Showing Server Info with .htaccess</p>
<pre>ServerSignature Off</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Prevent Downloading with .htaccess</p>
<pre><FilesMatch "\.(tex|log|aux)$">
Header set Content-Type text/plain
</FilesMatch></pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Allow Cross-Domain Fonts with .htaccess</p>
<pre><IfModule mod_headers.c>
<FilesMatch "\.(eot|otf|ttc|ttf|woff|woff2)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule></pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Auto UTF-8 Encode with .htaccess</p>
<pre># Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
# Force UTF-8 for a number of file formats
AddCharset utf-8 .atom .css .js .json .rss .vtt .xml</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Set Server Timezone with .htaccess</p>
<pre>SetEnv TZ America/Los_Angeles</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Switch to Another PHP Version with .htaccess</p>
<pre>AddHandler application/x-httpd-php55 .php</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Execute PHP with a different file extension with .htaccess</p>
<pre>AddType application/x-httpd-php .ext</pre>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="css-cheats">
<div class="row justify-content-between align-items-center">
<p class="col-xs-12 col-sm-12">Serve WebP Images Automatically from .htaccess</p>
<pre>RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]</pre>
</div>
</div>
</div>
</div>
</section>
<footer>
<p>Built & Maintained by <a target="_blank" href="https://www.facebook.com/stefanneropejcic">Stefan Pejcic</a></p><small></small>
</footer>
</div>
<script src="js/main.min.js"></script>
<script src="js/util.js"></script>
<script src="js/main.js"></script>
</body>
</html>