Htaccess Generator

Generate .htaccess rules with simple toggles.

WWW redirect
.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
</IfModule>

# Disable directory listing
Options -Indexes

Free online .htaccess generator. Toggle force HTTPS, www redirects, disabling directory listing and a custom 404 page to produce ready-to-use Apache .htaccess rules. Generated in your browser.

How to use the Htaccess Generator

  1. 01Toggle force HTTPS and choose a www redirect direction.
  2. 02Enable disabling directory listing or a custom 404 page if you need them.
  3. 03Copy the generated rules into your site's .htaccess file.

Frequently asked questions

Where does the .htaccess file go?

Place it in the document root of your site (or a subdirectory to scope rules to it). Apache must have mod_rewrite enabled and AllowOverride set for the rules to take effect.

Should I redirect www to non-www or the other way?

Either works — pick one and stay consistent so search engines see a single canonical host. This tool generates a 301 redirect for whichever direction you choose.