.htaccess Redirect Generator
Create Apache .htaccess page-level 301/302 rules plus HTTP → HTTPS and www / non-www redirects.
Page redirects
Paths must start with /. Spaces, quotes, braces and semicolons are not allowed.
Redirects for shared hosting
Sites on cPanel, Plesk and shared hosting (including WordPress) usually handle redirects in the .htaccess file in the site root. The .htaccess Redirect Generator prepares rules with the correct syntax for you.
Generated rules
- mod_alias Redirect lines for page redirects
- Forcing HTTP to HTTPS
- www to non-www, or the other way round (mod_rewrite)
Safe patterns
Host rules are created with escaped patterns, so dots and special characters don't cause unexpected matches. Paste the output at the top of your .htaccess file, and back up the file before making changes.
How to use .htaccess Redirect Generator
- Add old and new URL pairs.
- Choose the redirect type.
- Enable the HTTPS and www rules as needed.
- Paste the code at the top of your .htaccess file.
Why use this tool?
Create correct redirects for migrations and URL changes without knowing Apache syntax.
FAQ
My redirect doesn't work. What should I check?
Make sure mod_rewrite/mod_alias are enabled and AllowOverride permits .htaccess; 301s are cached, so clear the browser cache or test in a private window.
Where should I add the code in WordPress?
Above the # BEGIN WordPress block; otherwise WordPress rules may run first.
I use Nginx. Will this code work?
No, .htaccess only works on Apache and LiteSpeed. Use the Nginx Redirect Generator.
Related tools
Nginx Redirect Generator
Create Nginx 301/302 page redirects plus HTTP → HTTPS and www / non-www rules.
Open toolSecurity Headers Generator
Create CSP, HSTS, Referrer-Policy, Permissions-Policy and other headers for Nginx, Apache, IIS or Netlify.
Open toolCache-Control Header Generator
Create the right Cache-Control header with presets for static files, HTML pages and private data.
Open toolRobots.txt Generator
Create a robots.txt file with Allow, Disallow and sitemap rules for search engine bots.
Open tool