Skip to main content

.htaccess Generator

New

Build a common Apache .htaccess file for HTTPS redirects, www handling, caching, gzip, security headers, and SPA routing.

htaccessapacheredirectrewritehosting
Read the guide
Shortcuts:⌘ KSearch
Redirects
Caching & compression
Security headers
SPA / routing
.htaccess output
—

Generated for standard Apache with mod_rewrite, mod_headers, mod_deflate, and mod_expires enabled — the most common shared-hosting setup. Some managed hosts disable specific modules; if a directive has no effect, check your host's module list.

Continue with:

Frequently Asked Questions

What Apache modules does the generated config assume?

It assumes mod_rewrite (redirects/rewrites), mod_headers (security headers), mod_deflate (gzip compression), and mod_expires (browser caching) are all enabled — the standard set available on most shared Apache hosting.

Why isn't my directive working on my host?

Some managed or restrictive hosting providers disable specific Apache modules (most commonly mod_headers or mod_expires) or don't allow certain directives in .htaccess at all. Check your host's documentation or ask support which modules are enabled if a generated directive appears to have no effect.

What does the SPA fallback rule actually do?

It tells Apache: if the requested path doesn't match a real file or directory on disk, silently rewrite the request to index.html instead of returning a 404 — the standard pattern needed for client-side-routed single-page apps like React Router or Vue Router.

Can I combine "force www" and "force non-www"?

No — the tool only applies one at a time (www takes priority if both are somehow checked), since forcing both directions simultaneously would create a redirect loop.

Does this generator test my actual server?

No — it only assembles standard Apache directive text based on which checkboxes you select. It doesn't connect to your server or verify the directives will behave as expected in your specific hosting environment.

Related Tools