.htaccess Generator
Build a complete .htaccess file: 301/302 redirects, custom rewrite rules, forcing HTTPS or www, custom error pages, and directory settings.
General
Redirects
Rewrite rules (advanced)
Requires mod_rewrite and mod_aliasto be enabled on your Apache server (both are on by default on most shared hosting). Back up your existing .htaccess before replacing it, a bad rule can take a whole site down until it's fixed.
Frequently asked questions
What's the difference between a redirect and a rewrite rule?+
A redirect sends the visitor's browser to a different URL, they see the new address in their address bar. A rewrite rule serves different content for a URL without the browser ever knowing, the address bar stays the same. Use redirects for "this page moved," rewrites for "make /products/5 secretly load product.php?id=5."
Why 301 instead of 302?+
301 means "permanently moved" and tells search engines to transfer the old page's ranking signals to the new URL. 302 means "temporarily moved" and search engines keep indexing the original URL. Use 301 for a permanent change, 302 only if the redirect is genuinely temporary.
My .htaccess changes aren't doing anything, why?+
The most common causes: mod_rewrite isn't enabled on your server (most shared hosting has it on by default, but some don't), the .htaccess file isn't in the right directory, or a rule higher up in the file already matched and stopped processing (the [L] flag means "last rule, stop here").