SEO Generator

.htaccess generator

Редиректы, безопасность, кеширование и сжатие

Basic redirects

Custom redirects

Error pages

Security

Performance

.htaccess

# Generated by molotilo.digital .htaccess Generator
# 2026-07-24

# Directory Index
DirectoryIndex index.html index.php

# Security
Options -Indexes
<Files .htaccess>
Order allow,deny
Deny from all
</Files>

Important: Back up your .htaccess before replacing it. Incorrect rules can make the site unavailable.

.htaccess for SEO: the essential rules

What you configure via .htaccess

The key things for SEO: 301 redirects (merging www/non-www, HTTP→HTTPS, trailing slashes), caching static files (Expires/Cache-Control), gzip compression and blocking access to service files.

The generator assembles the needed blocks based on the selected options — you get ready code with comments.

Caution first

The .htaccess file is executed by the server on every request: an error in it takes the whole site down. Before changing it, save a copy, make edits step by step and check the site immediately.

After setting up redirects, check them with our redirect checker: the chain should collapse into a single 301 hop.

Frequently asked questions

What is the .htaccess file?+

A configuration file of the Apache web server, placed in a site directory. It is used to set up redirects, caching, compression, section protection and URL-handling rules without access to the main server config.

How do I redirect from HTTP to HTTPS?+

With a RewriteRule using the R=301 flag under the condition RewriteCond %{HTTPS} off. The generator creates a ready block — you just paste it at the start of .htaccess.

Does .htaccess work on Nginx?+

No, Nginx does not read .htaccess — rules are set in the server configuration. If you have Nginx (or Nginx in front of Apache), check the setup with your host: some rules need to be moved to the Nginx config.

What if the site returns a 500 error after changing .htaccess?+

Roll back the last change — there is a syntax error in the file. Edit .htaccess one block at a time and keep a backup of the working version.