Htaccess Redirect Generator
Generate .htaccess redirect rules for Apache servers. Create 301, 302, and other redirects with an easy visual interface.
Permanent redirect - Best for SEO, passes link equity
Redirect Rules
Quick Templates
Generated .htaccess
# Generated by Hazuu Tools - Htaccess Redirect Generator# 2026-06-09RewriteEngine On# Redirect www to non-wwwRewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]RewriteRule ^(.*)$ https://%1/$1 [L,R=301]
File Information
Testing & Validation
About Htaccess Redirect Generator
The .htaccess Redirect Generator builds ready-to-upload Apache server configuration files that handle URL redirections without requiring any command-line access or server expertise. You enter source paths and destination URLs, choose a redirect status code (301, 302, 303, 307, or 308), and the tool writes the exact RewriteRule syntax for you — including the required RewriteEngine On directive and optional flags like exact match and case-insensitive matching.
Apache mod_rewrite syntax is notoriously unforgiving: a misplaced flag, an unescaped special character, or a missing condition can silently break redirects or cause redirect loops. This generator handles all of that automatically. It also supports batch scenarios — domain migrations, forced HTTPS, www-to-non-www canonicalization, trailing-slash normalization, and WordPress path remapping — through dedicated quick-template presets that pre-fill the right rules in one click. A built-in URL tester lets you verify that a given path matches the expected rule before you upload the file.
All code is generated entirely in your browser using JavaScript. No URLs, domains, or configuration details are transmitted to any server, making it safe to use with internal staging domains or client sites. There is no account required, no watermark on the output, and no limit on how many rules you can generate.
Key Features
Five redirect status codes
Choose from 301 (permanent), 302 (temporary), 303 (See Other), 307 (temporary, method-preserving), and 308 (permanent, method-preserving) to match the exact HTTP semantics your situation requires.
Batch redirect rules
Add as many source-to-destination pairs as you need in a single file. Each rule independently supports exact-match and case-insensitive flags so you can mix strict and loose matching in one .htaccess.
Quick-template presets
Domain migration, HTTPS enforcement, WordPress path remapping, and clean URL (extension removal) configurations are available as one-click presets that pre-fill all the necessary rules and options.
Advanced server-level options
Configure www-to-non-www redirects, force HTTPS across the entire site, control trailing-slash behaviour (add or remove), and append any custom RewriteRule lines you already have.
In-browser URL tester
Type any path into the testing panel and see immediately which rule it matches and where it will redirect — before touching your live server.
Copy and download output
Grab the finished file with a single copy button or download it directly as a .htaccess file ready to drop into your web root.
How to Use
Configure Redirects
Choose a redirect type, add source and destination URLs for each rule, and toggle options like exact match or case insensitivity.
Use Advanced Options
Set up domain redirects, force HTTPS, manage trailing slashes, or apply quick templates for common scenarios.
Copy or Download
Review the generated .htaccess code, test URLs against your rules, then copy or download the file to upload to your server.
Example
A 301 redirect rule for a renamed blog post, with exact-match enabled. The generator writes the full RewriteRule directive including engine declaration and flags.
Redirect type: 301 - Permanent Redirect
Rule 1
From: /blog/old-post-title
To: /blog/new-post-title
Exact match: on
Case insensitive: off # Generated by Hazuu Tools - Htaccess Redirect Generator
# 2024-06-09
RewriteEngine On
# Redirect Rules
RewriteRule ^blog/old\-post\-title$ /blog/new-post-title [L,R=301] Common Use Cases
- arrow_circle_right
Preserving SEO equity after a URL restructure
When you rename slugs, move posts to a new directory, or redesign your site navigation, 301 redirects carry accumulated link equity and page authority to the new URLs. This tool lets you build those rules before you push the restructure live.
- arrow_circle_right
Migrating from HTTP to HTTPS
Activating an SSL certificate does not automatically redirect traffic. The Force HTTPS preset generates the RewriteCond and RewriteRule pair that Apache needs to send every HTTP request to its HTTPS equivalent, preventing duplicate-content penalties.
- arrow_circle_right
Moving to a new domain without losing traffic
A domain migration requires redirecting every path on the old domain to the corresponding path on the new one. The Domain Migration template writes the host-matching RewriteCond and a catch-all RewriteRule in one step, including an optional www redirect.
- arrow_circle_right
Canonicalising www vs. non-www
Search engines treat www.example.com and example.com as separate URLs unless you redirect one to the other. The www-redirect option generates the exact NC-flagged condition block that Apache needs to enforce your chosen canonical form.
- arrow_circle_right
Testing redirects before deploying to a live server
The built-in URL tester simulates which rule a given path would match and where it would land, so you can validate the logic without uploading anything or triggering actual HTTP responses on your server.