Web Dev & Coding

.htaccess Redirect Generator

The .htaccess Redirect Generator builds Apache redirect rules for you — custom old-to-new URL redirects with 301 or 302 status, plus common rules to force HTTPS and standardize www usage.

What is an .htaccess Redirect Generator?

The .htaccess file is a configuration file for the Apache web server that controls how the server handles requests for a directory and its subdirectories. One of its most common uses is defining redirects — sending visitors and search engines from an old URL to a new one. Writing these rules by hand is fiddly and easy to break.

This generator builds correct redirect rules for you. It supports two styles — the simple Redirect directive and the more flexible mod_rewrite RewriteRule — and includes ready-made common rules for forcing HTTPS and standardizing the www prefix.

How to Generate Redirect Rules

  • Choose a style: the Redirect directive or mod_rewrite RewriteRule
  • Pick 301 (permanent) or 302 (temporary) for the status code
  • Add each old path and its destination URL in the redirect rows
  • Toggle common rules like Force HTTPS or www handling as needed
  • Copy the generated block and paste it into your site's .htaccess file

301 vs 302 Redirects

A 301 redirect tells browsers and search engines that a page has moved permanently. Search engines transfer the old page's ranking signals to the new URL, which makes 301 the right choice for permanent moves, site migrations, and consolidating duplicate URLs.

A 302 redirect indicates a temporary move; search engines keep the original URL indexed. Use 302 for temporary maintenance pages, A/B tests, or short-term promotions where you intend to restore the original URL later. Choosing the wrong type can harm your SEO, so this distinction matters.

Common Redirect Scenarios

Forcing HTTPS ensures every visitor uses a secure connection, which is essential for security and is a confirmed ranking signal. Standardizing on either www or non-www prevents search engines from treating the two as separate sites with split ranking authority. Per-URL redirects preserve traffic and link value when individual pages move or are renamed. This tool generates all of these correctly so you avoid redirect loops and syntax errors.

Redirect Directive vs mod_rewrite

Apache offers two ways to redirect, and this generator supports both. The simple Redirect directive, provided by mod_alias, is ideal for straightforward one-to-one moves: you give it an old path and a destination, and it sends visitors there with the status code you choose. It is easy to read and perfectly adequate for the majority of page-level redirects.

RewriteRule, part of the more powerful mod_rewrite module, is the right tool when you need conditions and pattern matching — forcing HTTPS, canonicalizing the www prefix, or rewriting whole groups of URLs with regular expressions. It is more flexible but also easier to get wrong, since the order of rules and conditions matters. The generator writes correct syntax for whichever style you pick, so you get the right behaviour without memorizing the exact directive format.

Why Choose Our .htaccess Redirect Generator?

This generator is completely free, needs no signup, and runs entirely in your browser. It produces correct, ready-to-paste rules for both the Redirect directive and mod_rewrite, with the right status code and proper syntax — avoiding the redirect loops and typos that are so easy to introduce by hand. Built-in common rules for forcing HTTPS and standardizing the www prefix save you from looking up the canonical patterns every time.

The .htaccess Redirect Generator is one of more than 200 free tools on ToopTools. If you manage Apache sites or handle migrations, you can pin it to your personalized My Workspace workspace so it sits beside your other web-development utilities, always one click away. It works on any modern browser, on desktop and mobile.

Is the .htaccess redirect generator free?

Yes. It is completely free with no limits and no signup. You can generate as many redirect rules as you like, as often as you like, without ever creating an account.

When should I use a 301 instead of a 302?

Use a 301 (permanent) redirect for anything that has moved for good — renamed pages, site migrations, and consolidating duplicate URLs — because search engines transfer ranking signals to the new address. Reserve 302 (temporary) for short-term situations like maintenance pages or A/B tests, where you intend to restore the original URL later.

Will these rules work on Nginx?

No. The .htaccess file and its directives are specific to the Apache web server and compatible servers like LiteSpeed. Nginx uses a completely different configuration syntax for redirects, so these rules will not work there. Confirm your host runs Apache before using the generated file.

How do I force HTTPS with .htaccess?

Toggle the Force HTTPS common rule and the generator adds the correct mod_rewrite block that detects insecure requests and redirects them to the https version of the same URL. This ensures every visitor uses an encrypted connection, which is both a security best practice and a confirmed ranking signal.

Where do I put the generated rules?

Paste them into the .htaccess file in your site's root directory, creating the file if it does not exist. Changes take effect immediately on Apache, with no restart required. Always keep a backup of your existing .htaccess before editing, since a syntax error can affect how the whole site responds.

Tips for Safe Redirects

  • Back up your existing .htaccess before pasting in new rules
  • Use 301 for permanent moves to preserve SEO ranking signals
  • Pick one canonical host — www or non-www — and redirect the other to it
  • Avoid chains and loops by redirecting straight to the final destination URL
  • Test each redirect after deploying, including the HTTPS and www variations

Key Features

  • Generates both Redirect directive and mod_rewrite RewriteRule styles
  • Choose 301 permanent or 302 temporary status codes
  • Add multiple custom old-to-new URL redirects
  • One-click common rules for Force HTTPS and www handling
  • Ready-to-paste output for your site's .htaccess file
  • 100% browser-based and free to use

How do I create a 301 redirect in .htaccess?

Enter the old path and the new destination URL, choose the 301 (permanent) redirect type, and the tool generates the correct directive instantly. Copy it into your site's .htaccess file to send visitors and search engines to the new address.

Does the .htaccess redirect generator work offline?

Yes. The rules are generated entirely in your browser, so once the page has loaded the tool works without an internet connection and nothing you enter is uploaded. You can build redirect rules privately on your own device.

Related searches

htaccess redirect generatorhtaccess generator301 redirect generatorapache redirecthtaccess rewriteforce https htaccesswww redirect htaccess

Recommended Web Dev & Coding tools

Explore more free online tools related to .htaccess Redirect Generator.