How to use the .htaccess Redirect Generator
- 1. List redirectsEach line: the old path, a space, then the new path or full URL.
- 2. Choose site rulesForce HTTPS, and pick www or non-www, with your domain.
- 3. Add and testBack up .htaccess, paste the rules near the top and test each old URL.
What the example generates
The three sample redirects become RewriteRule lines such as RewriteRule ^old-page\.html$ /new-page/ [L,R=301]. Dots and other special characters in the old path are escaped so they match literally, and the ^ and $ anchors make sure /old-page.html does not also catch /old-page.html-backup. Above them sit two site rules: one sends example.com to www.example.com, and one sends any HTTP request to HTTPS, both straight to the final host so visitors hit a single redirect, not a chain.
If an old path includes a query string, such as /page?id=7, the tool adds a RewriteCond for it, because RewriteRule alone never sees the query part.
Before you upload
- These rules need Apache with mod_rewrite and AllowOverride enabled. Nginx ignores .htaccess; use a return 301 inside a server block instead.
- Back up the current file. One typo can make the whole site return a 500 error.
- Use 301 or 308 only for permanent moves, because browsers cache them for a long time.
- Redirect each old page to its closest new page, not everything to the home page.
If you use WordPress, put these rules above the # BEGIN WordPress block. Test old URLs in a private window to avoid cached redirects. Update internal links and the sitemap afterwards with the XML sitemap generator, and set canonicals with the canonical tag generator. For Nginx servers, start from the Nginx config generator.
Frequently asked questions
Why use RewriteRule instead of Redirect 301?
RewriteRule handles exact matching, query strings and host rules in one consistent system. Mixing Redirect and RewriteRule can run in an unexpected order.
How many redirects can .htaccess hold?
Hundreds are fine. For many thousands, a RewriteMap in the server config is faster, because .htaccess is read on every request.
Is the .htaccess Redirect Generator free?
Yes, the .htaccess Redirect Generator is free. The first time you generate your first rules, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.