Zahid Awais Get a free audit

Free htaccess generator

Build a complete Apache .htaccess file with HTTPS, caching, compression and security rules by ticking boxes.

By Zahid Awais · Technical SEO tools · Free, private, no sign-up

Result
0Sections
0Lines
0Bytes
    Htaccess Generator: what it does and an example result

    The free htaccess generator runs in your browser, needs no sign-up and never sends what you type anywhere.

    Quick answer

    This htaccess generator builds a ready to paste Apache .htaccess file from simple toggles: HTTPS and www redirects in one hop, browser caching, gzip compression, hotlink protection, custom error pages and basic security headers. Rule of thumb: back up the old file first, keep redirects to a single 301 hop and test the site right after uploading.

    What is a htaccess generator?

    An htaccess generator is a tool that writes per directory Apache configuration so you do not have to remember mod_rewrite, mod_expires, mod_deflate and mod_headers syntax. It combines the options you choose into ordered blocks, wraps module specific rules in IfModule checks so a missing module does not break the site, and merges HTTPS and www rules into one redirect.

    How do you use the Htaccess Generator?

    How to use the Htaccess Generator: enter details, see the result and copy it
    Real screenshot of the Htaccess Generator with the steps marked.
    1. Enter your domain and choose how HTTPS and www should be handled.
    2. Tick performance options: browser caching and gzip compression.
    3. Tick security options: hotlink protection, directory listing, sensitive files and security headers.
    4. Add custom 404 and 500 pages and the WordPress block if your site runs WordPress.
    5. Back up your current .htaccess, paste the new rules at the top of the file in your site root, then test key pages.

    Where is the .htaccess file located?

    The main .htaccess file sits in your site root, usually public_html or www, next to index.php. It is hidden because the name starts with a dot, so enable show hidden files in your file manager or FTP client. Apache explains how these files work in its .htaccess tutorial.

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

    A 500 Internal Server Error almost always means a syntax error or a directive your host does not allow. Restore your backup first, then add sections one at a time to find the faulty one. The IfModule wrappers in this tool reduce the risk when a module such as mod_headers is missing.

    Should I force HTTPS and www in .htaccess?

    Yes, pick one version of your site, usually https with or without www, and 301 redirect every other version to it in a single hop. This avoids duplicate URLs and redirect chains. Make sure your canonical tags, sitemap and internal links use the same version.

    Quick reference

    OptionApache moduleWhat it does
    Force HTTPS and wwwmod_rewriteOne 301 hop to your preferred host on https
    Browser cachingmod_expiresLets browsers reuse images, CSS and JS
    Gzip compressionmod_deflateCompresses text files before sending
    Hotlink protectionmod_rewriteBlocks other sites from embedding your images
    Security headersmod_headersAdds nosniff, frame and referrer headers
    Custom error pagescoreShows your own 404 and 500 pages

    Worked example

    Example

    Example: for example.com with HTTPS, non-www, caching, gzip and the WordPress block, the generator writes about 50 lines. A request for http://www.example.com/blog/ gets a single 301 to https://example.com/blog/, and images are cached for the period you chose instead of being downloaded on every visit.

    Frequently asked questions

    Does .htaccess work on Nginx?

    No. Nginx does not read .htaccess files at all, so these rules only work on Apache and LiteSpeed servers. On Nginx you add equivalent directives to the server block. Use our Nginx redirect generator for redirects on Nginx.

    Is .htaccess bad for performance?

    Apache checks for .htaccess files on every request when they are enabled, which adds a small overhead. If you control the server, the Apache docs recommend putting rules in the main config instead. On shared hosting, .htaccess is usually the only option and the cost is small.

    How long should browser caching be?

    For images, fonts, CSS and JavaScript, long cache times such as 1 year are safe when file names change on each update, like style.v2.css. If you overwrite files with the same name, choose 1 month so visitors get updates. HTML should not be cached long.

    Will hotlink protection block Google Images?

    This tool allows referrers from Google and Bing so your images can still appear and open from image search. It also allows empty referrers, which covers direct visits and many privacy tools. Only other websites embedding your images are blocked.

    Should I keep the WordPress block?

    Yes, if your site runs WordPress. WordPress needs its rewrite block for pretty permalinks, and it rewrites the section between BEGIN WordPress and END WordPress when you save permalinks. Put your custom rules above that block so they are not overwritten.

    Is this htaccess generator free and private?

    Yes. It is free with no sign up, and the file is generated entirely in your browser. Nothing you enter is sent to a server. Always keep a copy of your original .htaccess before replacing it.

    Sources

    Facts checked against these official pages. Read how I check facts in my editorial policy.

    Related free tools

    All 104 tools

    Robots.txt Generator

    A robots.txt generator is a tool that writes the plain text file crawlers read at the root of your site…

    Meta Robots Tag Generator

    A meta robots tag generator is a tool that writes the meta name="robots" element and the equivalent…

    Want a full audit instead?

    Send your website and I will check it for you, free.

    Get my free audit
    Chat on WhatsApp
    Free updates

    Get new tools, guides and coupons first

    One short email when something new goes live: articles, free SEO tools, package updates, discounts and price alerts. No spam, unsubscribe in one click.