RevealTheme logo

Generatore di frammenti .htaccess

Genera regole comuni per .htaccess: forzare HTTPS, reindirizzare www, impostare header di cache, abilitare Gzip.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Come usare questo strumento

  1. 1

    Open the dropdown and choose the rule you need (for example, Force HTTPS or Gzip compression).

  2. 2

    Read the generated snippet shown in the code box below the dropdown.

  3. 3

    Select the text and copy it, then paste it into your site's .htaccess file.

  4. 4

    Switch the dropdown to a different rule to view another snippet — combine several by pasting them one after another.

Che cos'è il generatore di frammenti .htaccess?

.htaccess è il file di configurazione per directory di Apache. Controlla la riscrittura degli URL, i reindirizzamenti, la cache, la compressione e gli header di sicurezza. Hostinger e la maggior parte degli hosting condivisi usano Apache (o LiteSpeed, che è compatibile). Questi frammenti coprono le esigenze più comuni.

Casi d'uso comuni

  • Forcing every visitor onto HTTPS after installing an SSL certificate on a shared Apache or LiteSpeed host.

  • Canonicalizing a domain to either the www or non-www version with a 301 redirect to consolidate SEO signals.

  • Adding a one-year browser cache to static assets so repeat visitors load CSS, JS, and modern image formats from cache.

  • Turning on Gzip compression for text responses to cut transfer size and improve page load time.

  • Hiding the contents of a folder that has no index file by disabling Apache's automatic directory listing.

  • Blocking PHP execution inside a public uploads directory so an attacker can't run a script they managed to upload.

Domande frequenti

.htaccess funziona su Nginx?
No: Nginx usa la propria sintassi di configurazione. Questi frammenti sono solo per Apache/LiteSpeed.
Dove devo collocare il file .htaccess?
Nella radice del suo sito (accanto a index.html). Le regole si applicano a quella directory e a tutte le sue sottodirectory.

Strumenti correlati