-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess
71 lines (57 loc) · 2.2 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
70
71
# Habilita o módulo de reescrita
RewriteEngine On
# Reescreve URLs amigáveis para arquivos .html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z-_]+)(/.*)?$ /$1.html [L]
# Redireciona URLs que contêm .html para URLs amigáveis sem extensão
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R=301,L]
# Reescreve URLs amigáveis para arquivos .php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
# Redireciona o diretório raiz para index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$ /index.html [L]
# Protege arquivos sensíveis
<FilesMatch "\.(env|git|gitignore|htaccess|htpasswd)$">
Require all denied
</FilesMatch>
# Desativa a listagem de diretórios
Options -Indexes
# Configuração de Cache
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
# Redireciona HTTP para HTTPS
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# Configuração de Segurança
<IfModule mod_headers.c>
# Protege contra ataques XSS
Header set X-XSS-Protection "1; mode=block"
# Protege contra cliques em CSRF
Header set X-Content-Type-Options "nosniff"
# Protege contra frame embedding
Header always append X-Frame-Options "SAMEORIGIN"
# Protege contra sniffing de conteúdo
Header set X-Content-Type-Options "nosniff"
# Define a política de segurança de conteúdo
Header set Content-Security-Policy "default-src 'self'; script-src 'self' https://cdnjs.cloudflare.com; style-src 'self' https://cdnjs.cloudflare.com; img-src 'self' data:; connect-src 'self';"
</IfModule>
# Protege contra Hotlinking
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?devthm\.site [NC]
RewriteRule \.(jpg|jpeg|png|gif|webp)$ - [F,NC,L]
</IfModule>