.htaccess Redirect Generator

🔧 Generate .htaccess redirect rules for URL redirections, www to non-www, HTTPS enforcement, and more.

Enter domain without http:// or https://

📚 Common Use Cases

  • www to non-www: Consolidate domain authority
  • Force HTTPS: Improve security and SEO
  • 301 Redirects: Preserve SEO value when moving pages
  • Trailing Slashes: Maintain URL consistency

🔍 SEO Best Practices

  • Use 301 redirects for permanent moves
  • Redirect to HTTPS for better rankings
  • Choose either www or non-www consistently
  • Test redirects after implementation

💡 Quick Examples

Redirect www to non-www:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

Force HTTPS:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]