Utinzo

.htaccess Generator

Generate an Apache .htaccess file with HTTPS redirects, www rules, caching headers, and custom error pages.

Generated Document
# Generated by Utinzo .htaccess Generator # https://utinzo.com/htaccess-generator # ── Disable Directory Listing ─────────────────────── Options -Indexes # ── URL Rewrites ───────────────────────────────────── <IfModule mod_rewrite.c> RewriteEngine On # Force HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Remove www RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ https://example.com/$1 [L,R=301] </IfModule> # ── Gzip Compression ───────────────────────────────── <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml AddOutputFilterByType DEFLATE text/css text/javascript AddOutputFilterByType DEFLATE application/javascript application/x-javascript AddOutputFilterByType DEFLATE application/json application/xml AddOutputFilterByType DEFLATE image/svg+xml </IfModule> # ── Browser Caching ────────────────────────────────── <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType text/html "access plus 1 day" </IfModule> # ── Custom Error Pages ─────────────────────────────── ErrorDocument 400 /400.html ErrorDocument 401 /401.html ErrorDocument 403 /403.html ErrorDocument 404 /404.html ErrorDocument 500 /500.html # ── Security Headers ───────────────────────────────── <IfModule mod_headers.c> Header always set X-Content-Type-Options "nosniff" Header always set X-Frame-Options "SAMEORIGIN" Header always set X-XSS-Protection "1; mode=block" Header always set Referrer-Policy "strict-origin-when-cross-origin" </IfModule>

This document is a template for informational purposes only and does not constitute legal advice. Consult a qualified attorney for your specific needs.

Did this tool work for you?

AdSense336 × 280
AdSense336 × 280

How to use this calculator

  1. 1

    Select your HTTPS and www preferences and enter your domain name.

  2. 2

    Toggle browser caching and Gzip compression on or off.

  3. 3

    Choose whether to prevent image hotlinking and disable directory listing.

  4. 4

    Select a PHP version hint if needed.

  5. 5

    Copy or download the .htaccess file and upload it to your website's root directory.

AdSense · 728 × 90

Frequently asked questions

What is an .htaccess file?

An .htaccess (hypertext access) file is a configuration file for Apache web servers. It lets you set URL redirects, enable compression, configure caching, block directories, set custom error pages, and more — all at the directory level without editing server config files.

Where do I upload the .htaccess file?

Upload it to your website's root directory (usually /public_html/ or /www/) via FTP or your hosting control panel's file manager. The file must be named exactly ".htaccess" with no other extension.

Will this work on Nginx or other servers?

No — .htaccess files are specific to Apache web servers. Nginx uses server block configuration files instead. Most shared hosting (cPanel, Plesk) runs Apache and supports .htaccess.

Can a wrong .htaccess file break my site?

Yes — a syntax error in .htaccess returns a 500 Internal Server Error for all visitors. Always keep a backup of your current .htaccess before replacing it. Most hosting providers let you restore via cPanel.

About .htaccess generator

Free .htaccess Generator

Why .htaccess matters for SEO

A properly configured .htaccess file directly impacts your SEO. HTTPS redirects ensure Google indexes your secure version. www/non-www canonicalisation prevents duplicate content penalties. Browser caching improves page speed, a confirmed Google ranking factor. Getting these right in .htaccess is faster and more reliable than plugin-based solutions.

Most important .htaccess rules

The three most important rules for any website are: (1) Force HTTPS — Google has required HTTPS since 2014 and marks HTTP sites as "Not secure". (2) www canonicalisation — pick one version and redirect the other consistently. (3) Enable Gzip — reduces page size by 60–80%, directly improving Core Web Vitals scores.

.htaccess Generator – Utinzo

Learn more from an authoritative source:

MDN Web Docs
Related tools

Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →

.htaccess Generator | Utinzo