.htaccess Redirect Generator
Build an Apache .htaccess file with 301 or 302 redirect rules, www normalization, forced HTTPS and a base rewrite block, then copy or download it.
.htaccess Redirect Generator — .htaccess Redirect Generator turns a list of old-to-new paths into a ready-to-paste Apache .htaccess file. Add one redirect rule per row with a status of 301 (permanent) or 302 (temporary), toggle www-to-non-www or non-www-to-www normalization, force HTTPS, and emit the RewriteEngine base block. Everything is assembled in your browser with plain JavaScript, so your URLs and redirect map are never uploaded anywhere.
What is .htaccess Redirect Generator?
.htaccess Redirect Generator is a free, browser-based tool that writes the mod_rewrite (RewriteRule and RewriteCond) directives an Apache web server reads from a .htaccess file. Developers, webmasters, and site migrators use it when they move pages, change a domain, or roll out HTTPS and need to send old URLs to new ones without losing search rankings or breaking bookmarks. You enter source and target paths in the redirect rows, pick 301 for a permanent move or 302 for a temporary one, and the tool prints a RewriteRule line for each pair. The www normalization option canonicalizes the host so example.com and www.example.com resolve to a single version, the force HTTPS option rewrites http to https, and the base rewrite checkbox prepends RewriteEngine On with a RewriteBase. Because the widget runs only in the browser, this text is the indexable description: generate Apache redirect rules, build an .htaccess 301 redirect, and force www and HTTPS.
How to use .htaccess Redirect Generator
- Add a redirect row and type the old path (Source) and the new path or URL (Target).
- Choose 301 for a permanent redirect or 302 for a temporary one in the status setting.
- Use the plus button to add more rows, or the trash button on a row to remove it.
- Turn on www normalization and pick whether to force www or non-www as the canonical host.
- Toggle Force HTTPS to redirect http traffic to https, and Base rewrite to include RewriteEngine On.
- Read the generated .htaccess in the output block, then click Copy or Download .htaccess.
Examples
Permanent page move
Input
/old-page → /new-page (301)
Output
RewriteRule ^old-page/?$ /new-page [R=301,L]
Force non-www and HTTPS
Input
www normalization: non-www, Force HTTPS on
Output
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]Temporary redirect to an external URL
Input
/promo → https://shop.example.com/sale (302)
Output
RewriteRule ^promo/?$ https://shop.example.com/sale [R=302,L]
Frequently asked questions
- What is the difference between a 301 and 302 redirect?
- A 301 is a permanent redirect: search engines transfer ranking signals to the new URL and browsers may cache it, so use it for moved or merged pages. A 302 is temporary: the original URL keeps its authority and the redirect is not cached long-term, which suits short-lived campaigns or maintenance pages. Pick the status per project in the settings panel.
- Where do I put the generated .htaccess file?
- Place it in the directory you want the rules to apply to, usually the document root of your Apache site, and name the file exactly .htaccess. The rules need mod_rewrite enabled and AllowOverride permitting .htaccess for that directory; the base rewrite option adds the RewriteEngine On line that turns the engine on.
- What does www normalization do?
- It picks one canonical host so a page is reachable at a single address. Choosing non-www redirects www.example.com to example.com, and choosing www does the reverse, each as a 301 so search engines consolidate on one version. This avoids duplicate-content issues from the same page existing under two hostnames.
- Can I redirect to an external domain?
- Yes. If a target starts with http:// or https:// the tool writes the full URL into the RewriteRule so the redirect points to another domain; otherwise it treats the target as a path on the same site. The source is matched as a path with an optional trailing slash.
- Is my redirect list sent to a server?
- No. The .htaccess text is assembled entirely client-side in your browser with plain JavaScript string building. Your source and target paths, domain, and options never leave the page and nothing is uploaded, so you can safely map private or internal URLs.
Related tools
Base32 / Base58 Encode / Decode
Encode text to Base32 (RFC 4648) or Base58 (the Bitcoin alphabet) and decode either one back to text, fully UTF-8 safe and entirely in your browser.
Base64 Encode / Decode
Encode text to Base64 or decode Base64 back to text (UTF-8 safe).
Case Converter & Counter
Change text case and count characters, words and lines.
Code Formatter & Minifier
Beautify or minify HTML, CSS and JavaScript instantly in your browser, with 2-space, 4-space or tab indentation and Terser-powered JavaScript compression.