Redirect rules
About this .htaccess redirect generator
This tool creates Apache mod_rewrite rules that send an old path to a new full URL. Each source is matched exactly, so /old-page does not accidentally redirect /old-page-extra. The optional slash setting can treat /old-page and /old-page/ as the same address.
Use 301 when a move is permanent and search engines should transfer signals to the new URL. Use 302 for a temporary move or while testing. Browsers and proxies may cache a 301, so check a 302 first when you are unsure.
These rules work only on Apache when mod_rewrite is enabled and .htaccess overrides are allowed. They do not work as Nginx configuration. Back up the existing file, add the rules near the top, test every old URL and watch for redirect loops.
What the generated flags mean
Old query parameters are the part after ?. Choose whether to append or discard them.
| Code | Meaning |
|---|---|
| 301 | Permanent move; can be cached and used by search engines as a long-term change. |
| 302 | Temporary move; the old URL remains the main address. |
| QSA | Appends the old query parameters to any parameters on the new URL. |
| QSD | Discards the old query parameters when the destination has none of its own. |
How to create .htaccess redirects
- Add old and new addresses: Put one pair on each line. Start the old path with / and use a complete https:// target.
- Choose 301 or 302: Use 302 for a test or temporary move. Select 301 only after the destination is final.
- Back up, publish and test: Add the code to the site-root .htaccess file and test the old URL, its query parameters and the final destination.
Frequently asked questions
Where do I put these rules?
In the .htaccess file in the Apache document root, usually near the top before broader rewrite rules. Back up the file first because a syntax error can cause a server error.
What is the difference between 301 and 302?
301 says the move is permanent and may be cached. 302 says it is temporary. Use 302 while testing; switch to 301 only when the new address will remain.
Will these rules work on Nginx or IIS?
No. The generated RewriteRule syntax is for Apache with mod_rewrite. Nginx and IIS use different configuration formats.
Why can a redirect loop happen?
A loop occurs when the destination is redirected back to the source, directly or by another broad rule. Test with a redirect checker and inspect all existing rules.