.htaccess 301 Redirect Rule Generator

Generate clean Apache .htaccess 301 redirect rules with optional HTTPS and non-www canonical enforcement.

Inputs

Build clean Apache redirect rules for HTTPS enforcement, non-www canonicalization, and 301 page moves.

Generated .htaccess

Ready to copy or download. Runs 100% in your browser.

RewriteEngine On

# Force HTTPS and canonical apex domain
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.ca$ [NC]
RewriteRule ^ https://example.ca%{REQUEST_URI} [R=301,L]

# Individual 301 redirects
Redirect 301 /old-services /services
Redirect 301 /plumbing-toronto.html /areas/toronto/plumbing
  • Back up your existing .htaccess file before deploying changes.

Common questions

Should redesign redirects use 301 or 302?

Use 301 permanent redirects so search engines transfer ranking signals to the new destination URL.

Where should HTTPS redirect rules sit in .htaccess?

Place RewriteEngine On and HTTPS rules above CMS front-controller rewrites so requests redirect in one hop.