.htaccess Generator Online

Toggle common Apache rules and copy a ready-to-use .htaccess, generated entirely in your browser.

Your domains, redirect paths, and IP addresses are processed locally in your browser to build the .htaccess, and nothing is uploaded to a server.

Setting file permissions? Try the chmod Calculator.

About .htaccess Generator

This .htaccess generator builds a valid Apache configuration file from toggles, so you do not have to memorise mod_rewrite syntax. Switch on the rules you need and the output updates live: force HTTPS, canonicalise www or non-www, add custom 301 redirects, deny specific IP addresses, set custom 404 and 500 error pages, enable gzip compression, turn on browser caching with mod_expires, disable directory listing, set a default DirectoryIndex, and add basic security headers like X-Frame-Options and Referrer-Policy. Rewrite-based rules are wrapped in a single mod_rewrite block with one RewriteEngine On, and every section gets a comment header so the file stays readable. It is built for developers and site owners moving a site to HTTPS or wiring up an apache redirect. The whole thing runs in your browser, so your domains, paths, and IPs never leave your device.

Features

How to use the .htaccess Generator

  1. Toggle on the sections you need, such as Force HTTPS or Browser caching.
  2. Fill in any inputs, like redirect from/to paths or IP addresses to block.
  3. Watch the .htaccess output build live in the panel on the right.
  4. Click Copy, or Download to save the file as .htaccess in your site root.

Example

Input

Force HTTPS: on
Force www / non-www: remove www
Redirect: /old-page -> https://example.com/new

Output

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Redirect all HTTP requests to HTTPS
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # Force non-www (strip www)
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^(.*)$ https://%1/$1 [L,R=301]

  # Custom 301 redirects
  RewriteRule ^old-page/?$ https://example.com/new [L,R=301]
</IfModule>

HTTPS, non-www, and a custom redirect share one mod_rewrite block.

Common errors & troubleshooting

Frequently asked questions

What is a .htaccess generator?
It is an in-browser tool that turns simple toggles and inputs into a valid Apache .htaccess file, covering HTTPS redirects, www canonicalisation, 301 redirects, IP blocking, compression, caching, and security headers, ready to copy or download.
How do I force HTTPS in .htaccess?
Enable the Force HTTPS toggle. It adds a mod_rewrite rule that checks RewriteCond %{HTTPS} off and 301-redirects every request to the https:// version of the same URL.
Where does the .htaccess file go?
Place it in the document root of your site (or the specific directory it should affect), name it exactly .htaccess with the leading dot, and make sure AllowOverride is enabled for that directory in your Apache config.
How do I set up a 301 redirect with this htaccess generator?
Turn on Custom 301 redirects, enter the old request path in the From field and the new URL in the To field, and add as many rows as you need; each becomes a RewriteRule with the [L,R=301] flags.
Does this work for Nginx too?
No. .htaccess is an Apache feature. Nginx ignores it and uses server-block directives in nginx.conf instead, so this output is for Apache or LiteSpeed servers.
Is my configuration sent anywhere when I generate it?
No. The .htaccess generator runs entirely in your browser, so the domains, paths, and IP addresses you enter are processed locally and never leave your device.

Related tools

All ArrayKit tools