301s, domain moves, HTTPS and canonical rules without tears.
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Whole-domain migration
RewriteCond %{HTTP_HOST} ^old-example\.com [NC]
RewriteRule ^(.*)$ https://new-example.com/$1 [L,R=301]
# Individual redirects
# /old-page → /new-page
RewriteRule ^old-page/?$ /new-page [R=301,L]🔧 Requires Apache with mod_rewrite enabled (near-universal on shared hosting). Place your rules before any conflicting blocks. Test with R=302 first and switch to R=301 once verified, so browsers don’t cache a wrong permanent redirect.
Apache applies RewriteRules top-down; the HTTPS and canonical-host blocks must precede individual redirects or they will chain through them and leak intermediate URLs into browsers.
Browsers cache 301s aggressively and there is no reliable un-cache. Ship new rules as R=302, verify every path, then flip to R=301. This generator emits 301 because that is the end goal.
The whole-domain block preserves paths automatically: old.com/any/path lands on new.com/any/path with one rule instead of thousands of lines. Update Search Console afterward to speed reindexing.
If directives seem ignored, check AllowOverride in the vhost config — shared hosts enable it; some performance-tuned setups disable .htaccess entirely in favor of main config.
The .htaccess Redirect Generator creates htaccess redirect generator on demand, right in your browser. Set the options you need, click generate, and the result is ready to copy. Because everything runs locally, nothing you enter or produce leaves your device.
Generators like this are useful when you need a specific output (a password, a UUID, a QR code, placeholder text) and don't want to install an app or trust an unknown website with your data. This tool is free, has no usage limits, and works the same on phone and desktop.
Common uses: people reach for this tool when they need to use a redirect old domain to new htaccess, htaccess rewrite rule examples, remove index.html from urls htaccess, or bulk 301 redirects from csv.
Browser-based tools like this one have a few real advantages over installed software or manual methods:
More tools you might find useful