Skip to content
en

.htaccess Generator

Builds an .htaccess file for Apache: HTTPS redirect, with or without www, compression, browser cache, security headers and your own 404 page.

Input

One main address instead of two

.env, .git and other dot files

Result

Fill in the fields – the result will appear here.

Report a problem
This will be sent with your message:
Advertisement

The .htaccess file

What the generator does

It builds an .htaccess file for the Apache server. The file sits at the site root and controls the site without access to the server settings. The generator writes only the rules you turned on.

Which rules there are

- HTTPS redirect – every visitor lands on the secure address. - With or without www – the site has one main address, not two. - Compression – HTML, CSS and JavaScript are sent smaller. - Browser cache – images and fonts are not downloaded again every time. - Security headers – the browser does not guess the file type and does not embed the site in someone else's frame. - Hidden files – .env and .git return 403. The .well-known folder stays open. - Custom 404 page – instead of the server's default error.

Why the site will not break

Every rule sits inside <IfModule>. If the host lacks the needed module, Apache skips that block. The generator shows which modules are needed.

Example

HTTPS, no www, compression, cache and a /404.html page. The result is six blocks and three modules: mod_rewrite, mod_deflate, mod_expires.

Common questions

Does this work on nginx?

No. Nginx does not read .htaccess; for it the rules go into the server config.

When should I turn on the HTTPS redirect?

Only once the certificate is installed. Otherwise the site stops opening.

What if I get a 500 error after replacing the file?

Put the old file back. Then turn the rules on one by one and find the one the host does not allow.

Apache documentation

  • Apache HTTP Server 2.4 – modules mod_rewrite, mod_deflate, mod_expires, mod_headers and the ErrorDocument directive.
Advertisement

Report a problem

This will be sent with your message: