.htaccess Generator
Build Apache .htaccess rules: RewriteRule redirects and internal rewrites, force HTTPS, www or non-www, trailing slashes and URLs without .php or .html. Every generated line comes with a comment that explains it. Runs in your browser; nothing is sent to a server.
Site-wide rules
Custom redirects and rewrites
Use * as a wildcard: /blog/* to /articles/* moves a whole folder. A query string in "From" (like /product.php?id=42) is handled with a RewriteCond automatically.
For Apache 2.4 and compatible servers such as LiteSpeed. Nginx does not read .htaccess. Keep a copy of your current file and test on a staging site before going live.
Also available as an open-source library and Chrome/Edge extension on GitHub (MIT licence).
How it works
- Enter — type or paste your values or text.
- Get the result — it is worked out in your browser.
- Adjust — change the inputs to compare, or copy the result.
Related tools
View allPrefer to just describe the task? The AI Assistant can convert, compress and resize files from a short instruction.
About .htaccess Generator
Before you start
.htaccess only works on Apache and servers compatible with it, such as LiteSpeed, which most shared hosting uses. Nginx ignores the file; there the same rules go into the server configuration instead. Download a copy of your existing .htaccess before changing it, and test on a staging copy of the site if you have one.
RewriteRule in one sentence
RewriteCond lines set a condition, the RewriteRule after them says which path to match and where to send it, and flags in square brackets change the behaviour: R=301 makes a permanent redirect, L stops processing further rules, NC ignores upper and lower case, QSA keeps the visitor's query string and QSD drops it.
Writing your own rules
"From" is the old path, such as /old-page. Add * as a wildcard to move a whole folder: /blog/* to /articles/* sends /blog/hello to /articles/hello. If the old address has a query string, such as /product.php?id=42, the generator puts it in a RewriteCond, because a RewriteRule pattern never sees the part after the question mark. Tick "From is a regular expression" to write the pattern yourself, for example ^item/([0-9]+)$ to /items/$1.
Redirect or rewrite?
A redirect (301 or 302) sends the browser to a new address, and the address bar changes. Use 301 when a page has moved for good, so search engines move its ranking to the new address; use 302 only for a temporary move. A rewrite happens inside the server: the visitor keeps seeing the clean address, such as /product/blue-shirt, while the server runs product.php?slug=blue-shirt.
The order of the rules
The generator writes the www and HTTPS redirects first, so an old http://www. link reaches the final address in one step. Your own redirects come next, then the clean-URL rules, then internal rewrites, and "send missing files to index.php" always comes last, because it would otherwise catch everything. All rules use mod_rewrite rather than the older Redirect directive, so they run in the order you see.
If something breaks
A "500 Internal Server Error" straight after editing almost always means a typing mistake or that mod_rewrite is not enabled. Restore your backup and add rules one block at a time. A page that keeps reloading ("too many redirects") means two rules send visitors back and forth; the generator warns when a rule's target matches its own pattern, and it often happens when the hosting panel or Cloudflare already forces HTTPS and the file does it again. Test in a private browser window, because browsers remember 301 redirects.
Rate this tool
Log in to leave a review.