HTACCESS Redirect Generator
Build Apache redirect rules for HTTPS, a canonical www or non-www hostname, legacy paths, wildcard redirects, and trailing slashes. Everything runs in your browser.
Redirect settings
Choose the rules you need. The output updates as you type.
.htaccess file, review the generated rules on a staging site, and keep the WordPress block intact if you use WordPress.
Generated .htaccess rules
Paste this snippet above the WordPress block in your .htaccess file.
No rules generated yet.
How the generator works
- Source paths are matched without the leading slash inside
RewriteRule, as Apache expects. - Wildcards become numbered captures. A source such as
/old/*can redirect to/new/$1. - Redirect loops, duplicate sources, unsafe protocols, and invalid destinations are blocked.
- Query strings are preserved by default and can be dropped for the custom rules.
- Existing files and directories are skipped by trailing-slash normalization.
Private by design: no URL, hostname, or redirect rule is uploaded. The generator runs entirely in your browser.
Before you edit .htaccess
Download a copy of the current file before making changes. If you use WordPress, place the generated rules above the # BEGIN WordPress line and leave the existing WordPress block intact. After uploading the file, test the old URLs, the canonical hostname, and a few normal pages. If something breaks, restore your backup immediately.
HTTPS, www, and redirect status codes
A 301 redirect tells browsers and search engines that a move is permanent. A 302 redirect is temporary. Use 301 for a lasting HTTPS or hostname change and 302 only while testing or during a short-lived campaign. If a proxy or CDN terminates HTTPS before Apache, the %{HTTPS} variable may need to be adjusted for your hosting environment.
Common mistakes to avoid
- Do not create a rule that redirects a URL to itself; it causes a redirect loop.
- Put specific redirects before broad wildcard rules so they remain reachable.
- Do not redirect every request to a destination that is also redirected.
- Keep the WordPress rewrite block in place instead of replacing it.