.htaccess Redirect Generator
Generate correct Apache .htaccess redirect rules in seconds — no need to remember RewriteCond and RewriteRule syntax. Pick a preset such as force HTTPS, www to non-www, a single old URL to a new one, or moving an entire domain, choose a 301 or 302 status, and copy the ready-made snippet. Every line comes with a plain-language explanation, and everything is built in your browser with nothing sent to a server.
Enter the bare domain without http:// or www — for example, example.com.
The current path to redirect from, starting with a slash, e.g. /old-page.html.
Where visitors should land — a full URL or a path such as /new-page.
All traffic (with the path kept) is sent to this domain.
Use 301 for permanent moves so search engines pass on ranking. Use 302 only for temporary changes.
Check your input
Add these lines to the .htaccess file in your site’s root folder:
What each line does
Back up your existing .htaccess before editing, then test the redirect in a private browser window. A wrong rule can take a site offline.
Your .htaccess code will appear here
Fill in the fields above to generate the redirect rules.
How to use
- Choose what to redirect: force HTTPS, www or non-www, a single URL, a whole domain, or trailing slashes.
- Fill in the fields shown for that preset — your domain, the old path, or the new destination.
- Select a 301 permanent or 302 temporary redirect.
- Read the line-by-line explanation to confirm the rule does what you expect.
- Copy the snippet and paste it into the .htaccess file in your site’s root folder.
Features
- Presets for HTTP to HTTPS, www to non-www, single URL, whole domain and trailing slashes
- Choose 301 permanent or 302 temporary for every rule
- Plain-language explanation of each RewriteCond and RewriteRule line
- Domain and path inputs are validated to catch typos before you paste
- Copy-ready output — no mod_rewrite syntax to memorise
- 100% in-browser: your domain and URLs never leave your device