Free Online Htaccess Generator for Apache Rewrites and Headers
Choose the rules you need and read back a complete .htaccess with the parts in an order that works. Rewrites come before the front controller, compression and caching are wrapped in the module guards that stop a missing module taking the site down, and the panel shows the order.
Keep a copy of your working file before you replace it. A single bad line here returns a 500 for every page on the site, including the one you would use to fix it.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
Why the Order Cannot Be Rearranged
The front controller has to be last, and redirects have to be first.
Rewrite rules are read from the top, and a rule ending in [L] stops the pass.
A front controller rule catches every request that is not a real file or directory and hands it
to index.php, so anything written after it never runs for those requests. That is
why a redirect added to the bottom of a Laravel or WordPress .htaccess appears to do nothing at
all: the front controller got there first.
Protocol and host rules go at the very top for a different reason. If you redirect
/old to /new before forcing HTTPS, a visitor arriving on
http://example.com/old gets two redirects instead of one, which costs a round trip
and loses a little link equity at each hop. Fixing the protocol and the host first means every
later rule is working on the final address.
Everything that is not a rewrite, the error pages, the file blocks, the compression and caching blocks and the headers, is order independent, so those are written after the rewrite section in a fixed grouping that stays readable. The panel on the left shows the order as it will be written, which is worth a glance before you paste.
How to Build an Htaccess File
A few steps, and nothing is uploaded.
What to Know About .htaccess
Including the mistake that returns a 500 for every page.
<IfModule> so that a host without mod_deflate, mod_expires or mod_headers serves your pages instead of a 500. The cost is that a typo inside a guard fails silently, so if caching seems to do nothing, check that the module is actually enabled.
Options, in which case that one line is enough to bring the site down until you remove it.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About the Htaccess Generator
.htaccess is Apache configuration that lives in a folder rather than in the main config, which makes it the only way to change server behaviour on most shared hosting. It can force HTTPS, move URLs, compress responses, set cache headers and lock files away, and it is read fresh on every single request, which is both why it works without a reload and why it is slightly slow.
The snippets that circulate online are the problem this page is for. They are written for different Apache versions, they mix 2.2 and 2.4 access syntax, they leave out the module guards, and they are pasted in whatever order they were found, which for rewrite rules is not a cosmetic issue. A redirect below a front controller rule never runs, and nothing tells you: the page just loads as normal.
So the ordering is fixed here and shown to you. Protocol first, then the host, then trailing slashes, then your redirects, then the front controller, because that is the sequence in which each rule sees the address the previous one produced. Access, compression, caching and headers come after, grouped and guarded. What you get is one file to paste, with comments saying what each block does, so the next person can read it.
Frequently Asked Questions
Order, modules, caching and why nginx cannot use this.
Options -Indexes is the usual suspect, since many shared hosts set AllowOverride to forbid it. Restore your backup, then add the sections back one at a time until it breaks; the last one you added is the culprit.[L] stops the rewrite pass, so anything after the catch-all that sends requests to index.php never runs. This page writes redirects above the front controller for exactly that reason.