.htaccess Generator
Generate Apache .htaccess with HTTPS redirects, security headers, hotlink protection, bad bot blocking, compression, caching and AI generation.
Free .htaccess Redirect Generator — 301, 302 & Custom Rules
Redirects are among the most common and impactful tasks in web server management. Moving a page to a new URL, forcing HTTPS, canonicalizing www vs non-www, redirecting entire folders, and fixing broken URL structures all require precise .htaccess redirect rules. Writing these rules manually requires understanding Apache's mod_rewrite syntax — a common source of errors. This free .htaccess Redirect Generator produces correct redirect rules for all common scenarios with no syntax knowledge required.
Choose your redirect type — 301 permanent, 302 temporary, WWW to non-WWW, non-WWW to WWW, HTTP to HTTPS, or custom URL mapping — fill in the source and destination, and get the exact .htaccess rule to paste into your file. The generator validates inputs and produces clean, correct Apache redirect syntax.
Using the wrong redirect type has real consequences for SEO. If you permanently move content to a new URL and use a 302 instead of a 301, Google keeps the old URL in its index and does not pass ranking signals to the new URL. Always use 301 for permanent moves.
Common .htaccess Redirect Rules
301 Permanent redirect. Use for permanently moved pages. Transfers SEO equity. Google updates its index to the new URL over time.
302 Temporary redirect. Use for genuinely temporary redirects during maintenance. Does not transfer SEO equity. Old URL stays in Google's index.
HTTP to HTTPS. Forces all HTTP traffic to the HTTPS equivalent. Essential for security and required for HSTS preloading. Google prefers HTTPS and may penalize HTTP.
WWW to non-WWW (or vice versa). Canonicalizes your domain to one consistent form. Prevents duplicate content issues and consolidates link equity.
Folder redirect. Redirects an entire directory to a new location. Useful when restructuring site architecture or migrating sections to a new URL pattern.
Related Tools
- Redirect Checker – Test and verify redirect chains on any URL.
- Robots.txt Generator – Generate robots.txt rules for your server.
- Nginx Config Generator – Generate redirect rules for Nginx servers.
Frequently Asked Questions
What is .htaccess?
Apache server config file for redirects, URL rewriting, and access control — per-directory.
301 vs 302?
301 = permanent, passes SEO equity. 302 = temporary, no equity transfer, old URL stays indexed.
Do I need Apache?
Yes — .htaccess only works on Apache. Use nginx.conf for Nginx servers.
Is this free?
Yes. Completely free, no account needed.