MentorMakers Login Sign up

Do More with MentorMakers

Free tools. Powerful features. Built for a smarter tomorrow.

  • 260 Free Tools
  • Most tools — no signup
  • Temporary files handled for processing
  • AI Assistant built in
  • Made in Pakistan
Explore All Tools

.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).

Free to useNo software to install — works in any modern browser.
No signup neededOpen the tool and start straight away.
Runs in your browserNothing you enter is sent to a server.
Works on mobileSame tool on your phone, tablet or desktop.

Prefer to just describe the task? The AI Assistant can convert, compress and resize files from a short instruction.

About .htaccess Generator

The .htaccess file gives instructions to an Apache web server for one folder of a website. This generator writes the rules for you: force HTTPS, choose www or non-www, tidy trailing slashes, hide .php or .html, and add your own RewriteRule redirects and rewrites. Every line it writes has a comment above it that says what the line does.

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.

Processing your file…
Large files, OCR and video can take a minute or two — please keep this page open.
Bookmark this page
Press Ctrl+D for quick access next time