.htaccess Redirect Generator — 301, www, Force HTTPS
DeveloperAn .htaccess redirect generator produces ready-to-paste Apache snippets for individual 301/302 redirects, www/non-www host canonicalization, and HTTP-to-HTTPS enforcement.
What is it
.htaccess is the per-directory configuration file of the Apache web server, where redirects are declared with the mod_alias Redirect directive or mod_rewrite RewriteRule. This tool generates individual old-path-to-new-URL redirects (301 permanent or 302 temporary), host canonicalization to www or non-www, and forced HTTPS rules. The snippets are Apache-specific; Nginx and other servers use different syntax.
How to use
- 1Pick the redirect type (individual, www, HTTPS).
- 2Enter the path list or your domain and choose 301 or 302.
- 3Copy the snippet into the .htaccess at your site root and verify with the redirect checker.
Reference
| Case | Code | Method |
|---|---|---|
| permanent page move | 301 | Redirect 301 /old-page /new-page |
| temporary move (test, campaign) | 302 | Redirect 302 /old-page /new-page |
| force HTTP → HTTPS | 301 | RewriteCond %{HTTPS} !=on + RewriteRule |
| www ↔ non-www canonical host | 301 | RewriteCond %{HTTP_HOST} + RewriteRule |
Sources & standards
- Apache mod_alias: Redirect directive - Apache HTTP Server
- Apache mod_rewrite documentation - Apache HTTP Server
FAQ
Are my paths or domain sent to a server?
No. Snippet generation runs in your browser only; nothing you type is transmitted.
What is the difference between 301 and 302?
A 301 is a permanent move that transfers link signals to the new URL, while a 302 is temporary and keeps the original URL indexed. Use 301 when the address change is final.
Why does my .htaccess rule not work?
.htaccess only applies to Apache, and requires AllowOverride to be enabled plus the mod_rewrite module loaded. Nginx and Caddy need different configuration syntax.