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

Rule 1

Quick Templates

Generated .htaccess

# Generated by Hazuu Tools - Htaccess Redirect Generator
# 2026-06-09
RewriteEngine On
# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]

File Information

0.20
KB
6
Lines
0
Redirect Rules

Testing & Validation

info

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.

star

Key Features

check_circle

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.

check_circle

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.

check_circle

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.

check_circle

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.

check_circle

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.

check_circle

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.

help

How to Use

01

Configure Redirects

Choose a redirect type, add source and destination URLs for each rule, and toggle options like exact match or case insensitivity.

02

Use Advanced Options

Set up domain redirects, force HTTPS, manage trailing slashes, or apply quick templates for common scenarios.

03

Copy or Download

Review the generated .htaccess code, test URLs against your rules, then copy or download the file to upload to your server.

code_blocks

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.

Configuration
Redirect type: 301 - Permanent Redirect
Rule 1
  From: /blog/old-post-title
  To:   /blog/new-post-title
  Exact match: on
  Case insensitive: off
Generated .htaccess
# 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]
lightbulb

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.

quiz

Frequently Asked Questions

What is an .htaccess Redirect Generator? expand_more
An .htaccess Redirect Generator is a tool that builds Apache server configuration files containing URL redirect rules. It lets you set up 301, 302, and other redirect types through a visual form instead of hand-writing mod_rewrite syntax, which reduces syntax errors and saves time.
What is the difference between a 301 and 302 redirect? expand_more
A 301 redirect is permanent and tells search engines to transfer all ranking power to the new URL. A 302 redirect is temporary, meaning the original URL retains its SEO value and search engines continue indexing it. Use 301 for permanent moves — page renames, domain migrations, HTTP-to-HTTPS — and 302 for short-lived changes such as A/B tests or maintenance pages.
When should I use 307 or 308 instead of 302 or 301? expand_more
HTTP/1.1 introduced 307 (temporary) and 308 (permanent) to guarantee that the request method is preserved across the redirect. Older 302 and 301 codes often caused browsers to switch a POST request to a GET on the redirected URL. If you are redirecting form submissions or API endpoints where the method matters, prefer 307 or 308.
Do I need to enable mod_rewrite on my server? expand_more
Yes. The generated rules depend on Apache mod_rewrite, which must be enabled on your server. Most shared hosting providers enable it by default, and cPanel-based hosts usually expose a toggle in the Apache settings panel. If you are unsure, check with your hosting provider or look for AllowOverride All in your Apache virtual-host configuration.
Where do I place the .htaccess file? expand_more
Upload the file to the root directory of your website — the same directory that contains your index.html or index.php. The file must be named exactly ".htaccess" with the leading dot and no extension. On Windows you may need to name it ".htaccess." (with a trailing dot) in Explorer before the OS saves it correctly.
How is this different from a UTM Builder? expand_more
A UTM Builder appends campaign-tracking query parameters (utm_source, utm_medium, etc.) to existing URLs for analytics purposes — it does not change how servers respond to requests. This .htaccess generator produces server-side redirect rules that change the HTTP response code and Location header Apache sends to a browser or crawler. They solve different problems: UTM parameters track where traffic came from; .htaccess redirects control where it goes.
Can I add custom rules the generator does not support? expand_more
Yes. The Advanced Options panel includes a Custom .htaccess Rules textarea where you can paste any valid Apache directive — RewriteCond blocks, Headers directives, Options settings, and so on. The generator appends them verbatim at the end of the generated file.
Is my data processed securely? expand_more
Yes. All .htaccess code is generated entirely in your browser using JavaScript. No URLs, domain names, or configuration details are sent to any server, so your internal staging environments and client site URLs stay private.