Free .htaccess Generator

Build an Apache 2.4 .htaccess file by ticking the rules you need: force HTTPS and www or non-www, 301/302 redirects, IP and user-agent blocking, custom error pages, GZIP compression, browser caching, hotlink protection, password protection and security headers. The file updates as you choose, is checked for mistakes that would break your site, and is generated entirely in your browser.

Basic Configuration

URL Redirects

Old path (starting with /, optionally with a ?query) โ†’ new path or full URL. 301 is permanent, 302 temporary.

No redirects configured

Block IP Addresses

An IPv4 or IPv6 address, a range such as 203.0.113.0/24, or a partial address such as 10.1 (blocks 10.1.*.*).

No IPs blocked

Block User Agents

Any request whose User-Agent contains one of these texts (ignoring case) gets 403 Forbidden. Empty rows are ignored.

No user agents blocked

Custom Error Pages

No custom error pages

Hotlink Protection

Password Protection

Security Headers

Sent with every response (mod_headers). Each one is independent.

Generated .htaccess

# Generated by ZipConvert - Free .htaccess Generator
# https://zipconvert.com
# Apache 2.4 syntax

# No rules configured. Enable options to generate .htaccess rules.

๐Ÿ“ Installation Instructions

  1. Download or copy the generated rules. Chrome and some other browsers save the download as htaccess without the dot, because downloads cannot start with a dot.
  2. Back up any existing .htaccess, then upload the file to your website's root folder (or the folder it should protect).
  3. Make sure it is named exactly .htaccess on the server.
  4. Open your site in a private window to test. If you see a 500 error, restore the backup and check your host's error log.

Requires Apache 2.4 (or LiteSpeed) with .htaccess overrides allowed. Nginx does not read .htaccess files.

How to create an .htaccess file for Apache, free and private

An .htaccess generator writes the Apache rules for you so you do not have to remember the syntax. Here, tick the options you need under Basic Configuration, add rows for URL redirects, blocked IPs, blocked user agents and custom error pages, and the Generated .htaccess panel updates as you go. Then click Copy or Download and upload the file to your site.

It runs in your browser; nothing is uploaded (you can check the Network tab in DevTools). Mistakes that would make Apache answer with a 500 error are listed under Check before uploading.

The output is Apache 2.4 syntax, which LiteSpeed also reads. Nginx does not read .htaccess files. The generator does not create a .htpasswd password file and does not read an existing .htaccess, so merge the new rules into your current file by hand. After uploading, confirm the result with the HTTP header viewer, which shows the redirect chain and response headers of a public URL.

Table of Use: common jobs and the rules they write

Common .htaccess jobs, the option to use in the generator and the Apache rules it writes
JobUseRules written
Send all visitors to HTTPSForce HTTPSRewriteCond %{HTTPS} off then RewriteRule โ€ฆ [L,R=301]
One canonical address (HTTPS and www, or non-www)Force HTTPS plus WWW ConfigurationA single combined 301 redirect, so visitors are not bounced twice
Move a pageAdd Redirect, 301Redirect 301 /old-page /new-page
Move a URL that has a query stringAdd Redirect with /page.php?id=5A RewriteCond on QUERY_STRING and a RewriteRule โ€ฆ [R=301,L,NE]
Block an address or rangeAdd IPRequire not ip 203.0.113.7 inside a RequireAll block
Block a botAdd AgentRewriteCond %{HTTP_USER_AGENT} AhrefsBot [NC] then RewriteRule ^ - [F]
Show your own error pageAdd Page, status 404ErrorDocument 404 /error-404.html
Compress text filesEnable GZIP CompressionAddOutputFilterByType DEFLATE โ€ฆ inside IfModule blocks
Cache images, fonts and scriptsEnable Browser CachingExpiresByType image/png "access plus 1 year" and similar lines
Stop other sites embedding your imagesEnable Hotlink ProtectionRewriteRule \.(jpe?g|png|gif|webp|avif|svg)$ - [NC,F]
Ask for a loginEnable Password ProtectionAuthType Basic, AuthUserFile, Require valid-user
Add security headersSecurity HeadersHeader always set X-Content-Type-Options "nosniff" and similar lines

Before you block an address, look it up with the IP address lookup; to see what a bot calls itself, paste its string into the user agent parser.

Features

  • Every common rule on one screen. Force HTTPS, www or non-www, redirects, IP blocking, user-agent blocking, custom error pages, GZIP, browser caching, hotlink protection, password protection and four security headers.
  • Check before uploading. The tool flags an invalid IP, a redirect that would loop, a path that does not start with /, an unusable .htpasswd path and similar mistakes, and it escapes user-agent text so a space cannot break the rule.
  • Safer defaults. GZIP, caching and header rules sit inside IfModule blocks, so a missing Apache module is skipped instead of causing an error. Caching is 1 year for images and fonts, and 1 month for CSS, JavaScript and PDF.
  • Blocking that combines correctly. Several user agents are joined with OR. With password protection and IP blocking both on, they share one RequireAll block, so a blocked address is refused even with the right password.
  • Copy or Download. The download is named .htaccess, though Chrome may save it as htaccess because downloads cannot start with a dot.
  • Private and free. No account, and nothing is stored: reloading resets every option.

Rules that rewrite URLs often need a second look at your crawl files, so update your sitemap and robots.txt afterwards.

How to use the .htaccess generator

  1. Under Basic Configuration, tick Force HTTPS, pick a WWW Configuration, and tick Enable GZIP Compression or Enable Browser Caching if you want them.
  2. To move pages, click Add Redirect and fill in the old path, the 301 or 302 type and the new path or URL. Use clean paths such as those from the slug generator.
  3. To block visitors, click Add IP or Add Agent. To show your own error page, click Add Page.
  4. Tick Enable Hotlink Protection, Enable Password Protection or any of the Security Headers you need, and fill in the fields that appear.
  5. Read the amber Check before uploading box, if it appears, and fix each item.
  6. Click Copy or Download. Back up your current .htaccess, upload the new file to your siteโ€™s root folder and make sure it is named exactly .htaccess.
  7. Open the site in a private window. After switching on HTTPS, check the certificate with the SSL certificate checker. If you see a 500 error, restore the backup.

Who can use it

  • Site owners on shared hosting who have Apache and an .htaccess file but no access to the server configuration.
  • WordPress and CMS users who need a redirect, a canonical host or a password on a folder without installing a plugin.
  • Developers, SEO specialists and students drafting 301 redirects for a site move, or learning mod_rewrite from commented output, then testing hand-edited patterns in the regex tester.
  • Webmasters moving DNS or hosts, who can confirm records with the DNS lookup tool before forcing www.

FAQs

How do I redirect HTTP to HTTPS with .htaccess?

Tick Force HTTPS. The generator writes RewriteEngine On, a condition that matches requests where HTTPS is off, and a rule that sends them to the same host and path over https:// with a 301. Your certificate must already work, or visitors will see warnings. Behind a proxy that talks to Apache over HTTP, it can loop.

How do I redirect one page to another with .htaccess?

Click Add Redirect, enter the old path starting with / (for example /old-page), choose 301 for a permanent move or 302 for a temporary one, and enter the new path or full URL. The tool writes a Redirect line. Apache also redirects everything below the old path, so the tool warns when the new address sits inside it.

How do I block an IP address in .htaccess?

Click Add IP and enter an address such as 203.0.113.7, a range such as 203.0.113.0/24, an IPv6 address or a partial address such as 10.1. The tool writes Require not ip lines inside a RequireAll block, which is Apache 2.4 syntax. An invalid entry is left out and listed under Check before uploading, because Apache would answer every request with a 500 error.

How do I block a bot by user agent in .htaccess?

Click Add Agent and type text from the botโ€™s User-Agent header, such as AhrefsBot. A request whose User-Agent contains that text, in any letter case, gets 403 Forbidden. Several entries are joined with OR. User agents are easy to fake, so this stops bots that announce themselves honestly, not determined scrapers.

How do I password protect a folder with .htaccess?

Tick Enable Password Protection, type a realm name for the login prompt and enter the absolute server path of your .htpasswd file. The tool writes AuthType Basic, AuthName, AuthUserFile and Require valid-user. It does not create the password file: make it on the server with the htpasswd command, ideally outside the public folder, and use this only over HTTPS.

Why do I get a 500 error after uploading .htaccess?

Apache answers every request with a 500 error when it cannot read a line: a typo, an unknown directive, a missing .htpasswd file or an override your host does not allow. This tool validates IPs, redirect paths and domains, and wraps GZIP, caching and header rules in IfModule blocks. If you still get a 500, restore your backup and check your hostโ€™s error log for the failing line.

Where do I upload the .htaccess file, and does it work on Nginx?

Back up any existing .htaccess, then upload the file to your siteโ€™s root folder, or the folder it should protect, named exactly .htaccess. Chrome saves the download as htaccess without the dot, so rename it on the server. It needs Apache 2.4 or LiteSpeed. Nginx ignores .htaccess files completely, so the rules must be rewritten as Nginx configuration.

Is my .htaccess configuration uploaded anywhere?

No. The file is built by JavaScript in your browser, so your domain, paths and IP addresses are never uploaded (you can check the Network tab in DevTools). Nothing is stored: reload the page and every option resets. It is free, with no account.