.htaccess Redirect Generator
Generate .htaccess redirect rules in both Redirect and mod_rewrite form, with 301 and 302 options for Apache servers.
How to use it
- Enter the destination — and the old path where the method needs one.
- Choose 301 for a permanent move or 302 for a temporary one.
- Copy the generated code into the right place for your server or page.
.htaccess is Apache's per-directory configuration file, and a redirect rule inside it runs before Apache even looks for the requested file — which makes it faster and more reliable than a redirect coded into a page. This generator writes the rule two ways: a plain Redirect directive, and the equivalent mod_rewrite RewriteRule, so you can use whichever your setup already relies on.
Redirect vs RewriteRule
Redirect (from mod_alias) is the simpler of the two — one old path, one new path, done. It is enough for straightforward one-to-one page moves and is easier to read and maintain later.
RewriteRule (from mod_rewrite) is a full pattern-matching engine: it can redirect whole groups of URLs that match a regular expression, preserve or rewrite query strings, and apply conditions based on the requesting domain, user agent or other request details. Reach for it when a single rule needs to cover many URLs at once; use plain Redirect when it does not.
When .htaccess causes a 500 error
This is almost always a syntax error in the rule itself, or a directive that depends on an Apache module — typically mod_rewrite — that is not enabled on that server. The Apache error log (not the browser) names the exact line and reason, and is the fastest way to find it; on shared hosting it is usually available through the control panel.
Questions people ask
Redirect or RewriteRule — which should I use?
Redirect is simpler and enough for one-to-one moves. RewriteRule handles patterns, conditions and query strings, at the cost of being harder to read.
My .htaccess causes a 500 error. Why?
Usually a syntax error or a module that is not enabled. Check the server error log — it names the offending line.
Is anything uploaded?
No. Everything runs in your browser — no file, image or snippet you use here ever leaves your device.
Last updated 22 August 2026