RevealTheme logo

Generador de Fragmentos .htaccess

Genera reglas comunes de .htaccess: forzar HTTPS, redirigir www, establecer cabeceras de caché, habilitar Gzip.

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

Cómo usar esta herramienta

  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.

¿Qué es el Generador de Fragmentos .htaccess?

.htaccess es el archivo de configuración por directorio de Apache. Controla la reescritura de URL, las redirecciones, la caché, la compresión y las cabeceras de seguridad. Hostinger y la mayoría de los alojamientos compartidos usan Apache (o LiteSpeed, que es compatible). Estos fragmentos cubren las necesidades más comunes.

Casos de uso comunes

  • 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.

Preguntas frecuentes

¿Funciona .htaccess en Nginx?
No: Nginx usa su propia sintaxis de configuración. Estos fragmentos son solo para Apache/LiteSpeed.
¿Dónde coloco el .htaccess?
En la raíz de tu sitio (junto a index.html). Las reglas se aplican a ese directorio y a todos sus subdirectorios.

Herramientas relacionadas