This repository has been archived by the owner on Oct 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.htaccess
60 lines (51 loc) · 1.59 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
# Maintenance
#ErrorDocument 503 /503.php
#RewriteEngine On
#RewriteCond %{REMOTE_ADDR} !^your_ip_here$
#RewriteCond %{REQUEST_URI} !/503.php$
#RewriteCond %{REQUEST_URI} !/pt-logo.png$
#RewriteRule .* - [R=503,L]
###Setup
# Index
Options +FollowSymLinks
DirectoryIndex home.php index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#HTTPS
# RewriteCond %{HTTP:X-Forwarded-Proto} !https
# RewriteCond %{HTTPS} off
# RewriteRule .* https://gabrieldn5j.altervista.org%{REQUEST_URI} [L,R=301]
# Remove php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteCond %{REQUEST_FILENAME}\.php ^(.*)\.php(.*)$
RewriteRule .* %1.php?%2 [QSA]
# alternative:
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^([^\.]+)$ $1.php [NC,L]
# Remove trailing slash (not working)
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)/$ /$1 [L,R = 301]
</IfModule>
# Cache handler
# source: https://host-academy.it/tutorial-wordpress/how-to-tutorial-wordpress/144-browser-caching-in-wordpress-con-htaccess
<IfModule mod_headers.c>
<FilesMatch "\\.(ico|gz)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\\.(jpe?g|png|gif|swf|flv|pdf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\\.(js|css)$">
Header set Cache-Control "max-age=3600, private"
</FilesMatch>
<filesMatch "\\.(html|htm)$">
Header set Cache-Control "max-age=300, public"
</filesMatch>
</IfModule>
### Errors
# Error 403
ErrorDocument 403 /403.php
# Error 404
ErrorDocument 404 /404.php