Skip to content
Developer Tools

.htaccess Redirect Generator

Generate Apache .htaccess redirect rules for common cases.

Instant ResultsNo Sign-up Required100% Free Utility

.htaccess & Server Redirect Architect

Generate Apache .htaccess and Nginx rules from common presets, or describe a custom rule for the AI to write.

301/308 = permanent (passes SEO signals) · 302/307 = temporary

Directive Summary

Sends every plain-HTTP request to the same URL on HTTPS, so visitors and search engines always use the secure version.

Configuration Notice

Enter your domain above. The Nginx rules use example.com until you do.

Configuration Notice

Behind Cloudflare (Flexible SSL), a load balancer or a proxy, %{HTTPS} is always off and this rule loops. Use the X-Forwarded-Proto variant shown in the comments.

# Force HTTPS (301 Moved Permanently)
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

# Behind a proxy/CDN, use this condition instead of the %{HTTPS} line:
# RewriteCond %{HTTP:X-Forwarded-Proto} !https

About .htaccess Redirect Generator

Generate clean Apache .htaccess rewrite rules and redirection configurations. Generate 301/302 permanent redirects, HTTP to HTTPS enforcement, non-WWW to WWW rewrites, custom 404 error pages, and hotlink protection.

Why Choose Our .htaccess Generator

FeatureSmart ToolverseOthers
Multi-Rule Generator
Generates HTTPS, WWW, 301 redirects, Caching & Security rules
Single redirect rule generator
Apache 2.4 Ready
Uses modern mod_rewrite and mod_headers syntax
Outdated Apache 2.2 syntax
Syntax Validated
Prevents 500 Internal Server Error misconfigurations
Prone to infinite redirect loops
1-Click Copy
Instant clipboard copy of ready-to-paste .htaccess code
Unformatted code snippets

Common Uses & Applications

Migrate legacy URLs during website redesigns, enforce site-wide HTTPS SSL encryption, prevent image bandwidth hotlinking, block malicious IP addresses, and configure clean URLs without .html extensions.

Frequently Asked Questions

An .htaccess (Hypertext Access) file is a configuration file used by Apache web servers to control directory-level server behavior, URL rewrites, redirects, access control, and browser caching.

Related Searches & Topics

apache 2.4 mod_rewrite syntaxprevent 500 internal server error htaccessclean urls without html extensionimage hotlink protection htaccessblock malicious ip addresses htaccessbrowser caching mod_headers configurationcustom 404 error document ruleseo canonical permanent 301 redirects

📖 Guides for the .htaccess Redirect Generator

🔧 You May Also Like

Need More Tools?

Explore our full suite of AI-enhanced tools, smart calculators, and developer utilities.

Browse All Tools