WEB · FREE
Build the Apache config for HTTPS, www, redirects, caching, compression and security headers — without a syntax error.
Generate a working .htaccess file: force HTTPS, settle the www question, add 301 redirects, switch on compression and caching, block directory listing and set the security headers, all wrapped in the IfModule guards that stop a missing module taking the site down.
Force HTTPS Force HTTPS
www
www
301 redirects
One per line: old path, then the new one
Compress text responses Compress text responses
Cache static assets for a year Cache static assets for a year
Result .htaccess # Do not list a directory that has no index file Options -Indexes <IfModule mod_rewrite.c> RewriteEngine On # Force HTTPS RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] # Remove www RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml AddOutputFilterByType DEFLATE application/javascript application/json AddOutputFilterByType DEFLATE application/xml image/svg+xml </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/webp "access plus 1 year" ExpiresByType image/avif "access plus 1 year" ExpiresByType font/woff2 "access plus 1 year" # HTML stays short so a deploy is visible immediately ExpiresByType text/html "access plus 0 seconds" </IfModule> <IfModule mod_headers.c> Header always set X-Content-Type-Options "nosniff" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set X-Frame-Options "SAMEORIGIN" Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()" # Only send HSTS once you are certain HTTPS works everywhere — it is # remembered by browsers and cannot be withdrawn quickly. # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains" </IfModule> Before you upload it Back up any existing .htaccess — this file replaces it, and WordPress, Laravel and most installers put their own rules in there. Upload it to the folder it should govern; rules apply to that directory and everything under it. Load the site straight after. A syntax error in .htaccess returns 500 for every page, not just the one you changed. Every block is wrapped in IfModule, so a server without mod_rewrite or mod_deflate ignores those rules rather than failing. Apache only. Nginx and Caddy do not read .htaccess and need the equivalent in their own config.
Copy
Copy as Markdown
Copy as CSV
Add security headers Add security headers
Stop directory listing Stop directory listing
Single-page app fallback to index.html Single-page app fallback to index.html
Custom 404 page
Block image hotlinking except from
Reset
Paste rows with a heading row; the columns it understands are: Force HTTPS, www, 301 redirects, Compress text responses, Cache static assets for a year, Add security headers, Stop directory listing, Single-page app fallback to index.html, Custom 404 page, Block image hotlinking except from. Up to 500 rows.
Run on every row
NEXT STEP
Questions about this tool? Ask us on WhatsApp, get a free quote for the work around it, or have us do it for you: a website that brings in enquiries, ₦450,000.
Websites, apps, cloud, automation and AI for businesses in Nigeria and anywhere else. We build it, host it, watch it and keep it running, and explain everything in plain language.
© 2026 SigmaDev Digital. All rights reserved.
To the bottom
We use Google Analytics to see which pages help and the Meta Pixel to measure our ads. Nothing loads unless you allow it.
Accept all
Reject all
Close
Settings