.htaccess Generator

Generate an .htaccess file for HTTPS, www and custom redirects — free Apache generator.

About

About the .htaccess Generator

Builds a ready-to-use Apache .htaccess file from a few common choices, like forcing HTTPS, www redirects and custom redirects.

Site owners moving to HTTPS use it to force every visitor onto a secure connection, while developers migrating old URLs use the custom redirects to send visitors from an old path straight to its replacement. It joins Toolapt's other free SEO tools, all usable without signing up and without any limit on repeat use.

Choose what to view about this tool

Guide

Using the .htaccess Generator

  1. 1

    Step 1

    Turn "Force HTTPS" on if you want every visitor redirected to the secure version of your site.

  2. 2

    Step 2

    Choose how to handle the www prefix — leave it, redirect to it, or redirect away from it.

  3. 3

    Step 3

    Add any custom redirects, one per line, as "/old-path /new-path".

  4. 4

    Step 4

    Optionally add custom error pages, one per line, as "404 /404.html", for any HTTP status code, then copy the generated .htaccess file.

  • Generates a Force HTTPS redirect rule with one toggle
  • Adds a www or non-www redirect rule depending on your choice
  • Turns a simple list of old-path/new-path pairs into individual redirect rules
  • Adds an ErrorDocument directive for every status code you list, not just 404
  • Runs entirely in your browser — your settings are never uploaded anywhere
  • Free to use, with no limit on how many times you run it
  • Fully responsive, so it works just as well on a phone as on a desktop

Site owners moving to HTTPS

Site owners moving to HTTPS use the .htaccess Generator for forcing every visitor onto the secure version of the site with one rule.

Developers migrating old URLs

Developers migrating old URLs use the .htaccess Generator for redirecting a batch of retired paths straight to their replacements.

Site owners standardizing on www or non-www

Site owners standardizing on www or non-www use the .htaccess Generator for making sure every visitor lands on the same canonical domain form.

DevOps engineers

DevOps engineers use the .htaccess Generator for quickly producing a baseline .htaccess file for a new Apache-hosted site.

Examples

.htaccess Generator examples

4 worked examples

01

Force HTTPS only

With Force HTTPS on and www left as-is, the generated file adds "RewriteCond %{HTTPS} off" followed by a rule that 301-redirects every request to https://.

02

Redirect to www

With Force HTTPS on and www handling set to "Redirect to www", the output has 2 rewrite rules: HTTPS is enforced first, then www.example.com is made canonical.

03

Old page redirect

Enter "/old-page.html /new-page.html" as a custom redirect to get a "Redirect 301 /old-page.html /new-page.html" line — one such line is added per redirect entered.

04

Custom error pages

Enter "404 /404.html" and "500 /500.html" as custom error pages to get "ErrorDocument 404 /404.html" and "ErrorDocument 500 /500.html" appended — one line per status code entered.

FAQ

Frequently asked questions

Quick answers to common questions about the .htaccess Generator.

What does the .htaccess Generator do?

It builds a ready-to-use Apache .htaccess file from your choices about HTTPS, www handling, custom redirects and custom error pages.

Is the .htaccess Generator free to use?

Yes. It's free, with no sign-up, no watermark and no limit on how many times you use it.

Is my input safe when I use this tool?

Yes. The file is generated entirely on your own device — nothing you enter is sent to a server.

Where do I put the generated .htaccess file?

Upload it to the root directory of your Apache-hosted site (or the directory you want the rules to apply to). It has no effect on servers that don't run Apache with mod_rewrite enabled.

What format do custom redirects need to be in?

One per line, as "/old-path /new-path" — an old path, a space, then the new path it should redirect to.

Can I add error pages for codes other than 404?

Yes. Add one line per status code, as "500 /500.html" — any HTTP status code works, such as 400, 401, 403, 404 or 500.

Does this work on non-Apache servers?

No. .htaccess files are an Apache-specific mechanism; servers like Nginx use a different configuration format and won't read this file at all.

Can I use the .htaccess Generator on my phone?

Yes. The page is fully responsive and works on mobile, tablet and desktop browsers alike.

Does the .htaccess Generator have any limitations?

It covers the most common rules — HTTPS, www handling, simple redirects and custom error pages — rather than every possible mod_rewrite directive; advanced rules still need to be added by hand.

Still have a question? Contact us

Report a problem

.htaccess Generator

What went wrong?
    or paste a screenshot