Gerador de .htaccess
Gere regras .htaccess do Apache para redirecionamentos, reescritas e segurança.
Regras do Apache
Combine redirecionamentos, cache e roteamento SPA em um arquivo .htaccess pronto para baixar.
Requer Apache 2.4 e os módulos correspondentes com permissões AllowOverride. Teste em ambiente de staging. Atrás de um proxy que encerra TLS, configure primeiro a detecção confiável de HTTPS no servidor.
Redirecionamentos canônicos apontam para o domínio fixo acima. Com Forçar HTTPS desativado, o esquema HTTP ou HTTPS atual é preservado. Redirecionamentos permanentes podem ficar em cache nos navegadores.
.htaccess
# Generated by KitLocal — Apache 2.4; AllowOverride must permit these directives.
RewriteEngine On
# Canonical redirect (fixed host avoids trusting HTTP_HOST).
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json application/javascript image/svg+xml
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
</IfModule>
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
26 linhas893 bytes.htaccess