Free .htaccess Redirect Generator
Generate Apache rewrite rules, 301/302 redirects, HTTPS forcing, and maintenance mode rules instantly for your website.
301 Redirect
Permanent302 Redirect
TemporaryRewrite
Clean URLsWWW
Host CheckHTTPS
SSL ForceMaintenance
503 Status301 Permanent Redirect
302 Temporary Redirect
URL Rewrite
() to capture.$1 for first capture group.Domain Rewrites
Force HTTPS
This rule forces all traffic to use HTTPS.
Maintenance Mode (503)
RewriteEngine On is present at the top of your file.
How to Use the .htaccess Redirect Generator
Creating Apache rewrite rules is quick and easy with our free online .htaccess generator. Follow these simple steps:
- Select redirect type - Choose from 301 Permanent, 302 Temporary, URL Rewrite, WWW/non-WWW, Force HTTPS, or Maintenance Mode.
- Enter the required URLs - Fill in the old URL/path and new destination. For rewrites, enter the friendly URL pattern and actual file path.
- Generate the rule - Click the generate button to create your .htaccess code with proper syntax and flags.
- Copy the code - Click "Copy" to copy the generated rule to your clipboard.
- Add to .htaccess - Paste the code into your .htaccess file. Remember to add
RewriteEngine Onat the top if not already present.
Understanding HTTP Redirect Types
Choosing the right redirect type is crucial for SEO and user experience. Here's what each status code means:
Use when: A page has permanently moved to a new URL.
- Passes ~90-99% of SEO link equity
- Browsers cache this redirect
- Search engines update their index
- Best for site migrations and URL changes
Use when: A page is temporarily at a different URL.
- Doesn't pass SEO value to new URL
- Browsers don't cache this redirect
- Search engines keep the original URL indexed
- Good for A/B testing or temporary maintenance
Common .htaccess Use Cases
Here are the most common scenarios where you'll need .htaccess redirect rules:
Website Migration
Redirect old URLs to new ones when redesigning your site or changing URL structure.
Force HTTPS
Automatically redirect HTTP visitors to the secure HTTPS version of your site.
Clean URLs
Rewrite ugly URLs like /product.php?id=123 to friendly URLs like /product/123.
Best Practices for .htaccess Redirects
- Always backup existing .htaccess before editing
- Test in incognito to avoid browser cache issues
- Use 301 for permanent moves to preserve SEO
- Order matters - more specific rules should come first
- End rules with [L] flag to stop processing
- Avoid redirect chains (A→B→C) - redirect directly to final URL
- Check for loops that cause infinite redirect errors
- Use absolute URLs when redirecting to external domains
Frequently Asked Questions About .htaccess Redirects
RewriteCond %{HTTPS} off before HTTPS forcing, 2) Conflicting rules, 3) Both www and non-www redirects active. Use browser developer tools (Network tab) to trace the redirect chain.
RewriteEngine On enables the Apache mod_rewrite module for URL rewriting. This line must appear once at the top of your .htaccess file before any RewriteRule or RewriteCond directives. Without it, your rewrite rules won't work.