> htaccess --generate

Free .htaccess Generator for Redirects and HTTPS

Build a clean .htaccess file for Apache and LiteSpeed in minutes. Force HTTPS, fix www, redirect old pages, add caching and security headers, then copy the code. No coding needed.

5.0 (1 rating) · Built and tested by the SpellMistake team · Your data stays private
AT A GLANCE
  • What it doesWrites .htaccess rules from simple options
  • AccuracyRule-based, follows Apache docs
  • Works withApache and LiteSpeed servers
  • PriceFree, no sign-up, no limit
  • Last reviewed
Start from
HTTPS and www
www in the address
Slash at the end of URLs
Redirects
Speed
Security
Error pages and WordPress
Your .htaccess
Before you upload
    > define

    What Is an .htaccess Generator?

    Short answer
    An .htaccess generator is a tool that writes server rules for you. You pick what you need, such as forcing HTTPS or redirecting an old page, and it creates the .htaccess code for Apache or LiteSpeed servers. You paste the code into the .htaccess file in your website’s root folder.

    The .htaccess file tells your server how to handle requests before your page loads. One wrong character can take your whole site offline with a 500 error, so writing these rules by hand is risky. The generator uses tested rule patterns and puts them in the right order, so redirects run first and nothing clashes.

    Quick facts
    > how --to

    How to Use the .htaccess Generator

    Make a working .htaccess file in five simple steps.
    01

    Pick a preset or start blank

    Choose HTTPS, Speed, Security or WordPress to turn on the most common rules at once.
    02

    Set your domain and URL style

    Enter your domain, then choose to add or remove www and the slash at the end of URLs.
    03

    Add redirects

    List old and new page addresses, one pair per line, or move the whole site to a new domain.
    04

    Turn on speed and security rules

    Add caching, gzip, security headers, hotlink protection or block bad bots and IPs.
    05

    Copy and test

    Back up your current file, paste the new code, then load a few pages to check that everything works.

    Before you upload

    • Back up first. Download your current .htaccess so you can undo any change in seconds.
    • Find the file in your site’s root folder (often public_html). Turn on “show hidden files” in your file manager.
    • WordPress: keep the # BEGIN WordPress block. The generator adds it for you when you pick the WordPress preset.
    • Got a 500 error? Put your backup back, then add rules one group at a time to find the problem.
    Ready to try it? It is free and takes less than a minute.
    > ls ./guide

    What Each .htaccess Rule Does

    A quick reference for every option in the generator.
    RuleWhat it doesWhen to use it
    Force HTTPSSends every http:// visit to https:// with a 301 redirectAlways, once your SSL certificate works
    www or non-wwwPicks one version of your domain so Google sees one siteAlways. Pick one and keep it.
    Trailing slashAdds or removes the slash at the end of URLsWhen pages load with and without the slash
    Page redirects301 redirect from an old URL to a new oneAfter you move, rename or delete a page
    Move siteSends every URL to the same path on a new domainWhen you change domain names
    Caching and gzipTells browsers to keep files and makes files smallerTo speed up repeat visits
    Security headers and HSTSAdds browser safety headers and keeps visitors on HTTPSWhen your whole site works on HTTPS
    Hotlink protectionStops other sites from showing your imagesWhen others steal your bandwidth
    Block bots and IPsReturns 403 Forbidden to bad bots or addressesWhen spam or scrapers hit your site
    > cat methodology.md

    How the .htaccess Generator Works

    Here is what happens between your choices and the finished file.
    1. 01

      You choose options

      Each switch maps to a tested rule group, based on the Apache documentation.

      In your browser
    2. 02

      Inputs are checked

      Domains, paths and redirect lines are cleaned. Lines that cannot work are skipped and you are told why.

      In your browser
    3. 03

      Rules are put in a safe order

      Redirects come first, then HTTPS and www in one hop, then speed, security and WordPress rules.

      In your browser
    4. 04

      Risky settings are flagged

      For example HSTS without an HTTPS redirect, or hotlink protection without your domain.

      In your browser
    5. 05

      Clean code is built

      Each group is wrapped in comments and IfModule checks, so missing server modules do not break the site.

      In your browser

    One-hop HTTPS and www: the generator joins both checks so a visitor to http://example.com lands on https://www.example.com in a single 301 redirect, not two. Fewer hops means faster pages and cleaner signals for Google.

    Redirect format: RewriteRule ^old-page/?$ /new-page/ [R=301,L]. R=301 means “moved for good” and L stops other rules from running after it.

    Proxy and Cloudflare: if your site sits behind a proxy, the HTTPS check uses the X-Forwarded-Proto header so you do not get a redirect loop.

    Rule Patterns We Use

    These are the core rules behind the most used options.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    # HTTPS and www in one redirect
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
    </IfModule>
    Rules sit inside IfModule blocks, so the file stays safe if a module is missing.
    > test --report

    Is the .htaccess Generator Accurate?

    Yes. The generator builds every rule from tested patterns that follow the official Apache documentation, so the same choices always give the same, valid code.
    Rule-based
    accuracy level
    same input, same output
    Apache
    what results are based on
    official mod_rewrite rules
    Monthly
    full re-test
    against known answers
    24/7
    bug reports open
    fixed as high priority
    What we test every month

    Accuracy in plain words

    The output is exact: it is the code for the options you chose. What can differ is your server. Some hosts turn off modules like mod_headers, and some use Nginx, which ignores .htaccess. That is why you should always test after upload.

    Keep in mind
    Correct code is only safe if it suits your server. Always back up your old file and test a few pages after you upload the new one.
    > features

    Features of the .htaccess Generator

    Everything you need for a safe, fast and secure .htaccess file.

    HTTPS and www

    Force HTTPS and pick www or non-www in a single 301 redirect.

    Bulk redirects

    Paste many old and new URLs at once, or move a whole domain.

    Speed rules

    Browser caching and gzip compression for faster pages.

    Security rules

    Security headers, HSTS, hotlink protection and bot blocking.

    WordPress ready

    Keeps the WordPress block and can block xmlrpc.php.

    Safety warnings

    Flags settings that could cause loops or broken images.

    > limits --honest

    Limitations of This Tool

    No tool does everything. Here is what this one does not do, and what you should do yourself.
    What the tool cannot do
    What you should do
    > whoami

    Who Can Use This .htaccess Generator?

    Anyone who runs a website on Apache or LiteSpeed hosting.

    WordPress site owners

    Force HTTPS, fix www and speed up your site without a plugin.

    SEO specialists

    Set up clean 301 redirects after a redesign or site move.

    Web developers

    Get a tested starting file and save time on every project.

    Small business owners

    Fix "not secure" warnings and duplicate site versions on your own.

    > git log

    Updates, Bug Fixes and Reviews

    We test this tool every month and fix reported bugs as a high priority. Every change is listed here.
    Oct 2026

    .htaccess Generator launched

    First release with HTTPS, www, slash, redirects, caching, gzip, security headers, hotlink, bot and IP blocking, and 4 presets.

    Launch
    Every month

    Full re-test and rules review

    We run the tool against our test cases again and check the Apache documentation and Google redirect guidance for changes.

    Monthly

    Tool page last reviewed on .

    Found a bug or a wrong result?

    Tell us what you entered, what happened and what you expected. Our developer checks every report, fixes confirmed bugs as a high priority and tests the fix before it goes live.

    > git blame

    Who Built and Reviewed This Tool

    The SpellMistake team built this tool from our own daily SEO work and official rules.
    H
    Built and tested by

    Hassan

    Senior Web Developer, 4+ years
    Built the generator, the rule patterns and the safety warnings.
    MA
    Reviewed by

    Muhammad Ahtesham

    SEO Strategist and Founder, 4+ years
    Checked every redirect and HTTPS rule against Apache docs and Google guidance.
    A
    Guide and help text

    Afza

    Marketing Expert and Co-founder, 4+ years
    Made the labels, tips and this guide simple and easy to follow.

    Our standards

    This page follows our Editorial Policy and Methodology. If something here is wrong, our Corrections Policy explains how we fix it. Learn more about the SpellMistake team.

    > rate --tool

    Ratings From Real Users

    Did this tool help you? Your rating helps other people find a tool they can trust.
    5.0out of 5

    Based on 1 real user rating

    • 5 ★1
    • 4 ★0
    • 3 ★0
    • 2 ★0
    • 1 ★0

    Rate this tool

    How useful was the .htaccess Generator for you?

    Ratings come from real visitors. One rating per person. We never add, edit or remove ratings.

    > faq

    .htaccess Generator FAQ

    Quick answers to the questions people ask most about this tool.

    What is an .htaccess file?

    An .htaccess file is a small settings file for Apache and LiteSpeed servers. It controls redirects, HTTPS, caching, security and more for the folder it sits in and every folder below it.

    Where is the .htaccess file?

    It is in the root folder of your website, often called public_html or www. Files that start with a dot are hidden, so turn on "show hidden files" in your file manager or FTP app.

    Is this .htaccess generator free?

    Yes. It is 100% free, with no sign-up and no limits. Everything runs in your browser.

    How do I force HTTPS with .htaccess?

    Turn on Force HTTPS in the generator, enter your domain and copy the code. It adds a 301 redirect that sends every http:// request to https://. Make sure your SSL certificate works first.

    How do I redirect an old page to a new page?

    Add the old path and the new path as one line in the redirects box. The generator writes a 301 rule, which tells Google the page has moved for good and passes its value to the new URL.

    Why did my site show a 500 error after editing .htaccess?

    A 500 error usually means a rule your server does not support or a typing mistake. Put your backup file back, then add rules one group at a time to find the cause.

    Does .htaccess work on Nginx?

    No. Nginx does not read .htaccess files. Nginx rules go in the server config instead, so ask your host to add them for you.

    Want the technical side fixed for you?
    Our technical SEO team finds and fixes crawl, index, speed and server problems across your whole website.