.htaccess Redirect Generator

Create 301 and 302 rewrite rules for Apache servers instantly

Generate Redirect Rules

How It Works

Apache .htaccess redirect rules use the mod_rewrite module. Each rule starts with RewriteEngine On, followed by conditions (RewriteCond) and the redirect directive (RewriteRule). The pattern matches the requested URL path using regular expressions. The flags at the end control behavior: [R=301,L] means a permanent redirect (301 status code) and stops processing further rules (L = last). For 302 redirects, the flag is [R=302,L]. The QSA flag appends any query string parameters. Domain checks use %{HTTP_HOST} to match the requested hostname. Rules are processed top-to-bottom, so ordering matters when multiple rules exist.

Frequently Asked Questions

What is the difference between a 301 and 302 redirect in .htaccess?
A 301 redirect is a permanent redirect that tells search engines the page has moved permanently, passing link equity to the new URL. A 302 redirect is temporary, indicating the page is temporarily moved. Use 301 for permanent changes and 302 for temporary ones like maintenance pages.
How do I redirect all HTTP traffic to HTTPS using .htaccess?
Add a RewriteCond checking for HTTPS off, then a RewriteRule that redirects all traffic to the HTTPS version: RewriteCond %{HTTPS} off, followed by RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]. This ensures all visitors are automatically redirected to the secure version.
Will .htaccess redirects affect website performance?
A small number of .htaccess redirects have negligible impact on performance. However, redirect chains (A→B→C) can slow load times and hurt SEO. Best practice is to redirect directly to the final destination and keep your .htaccess file clean with minimal rules.

Related Tools

Free tools by TUNA — energy supply from vetted manufacturers