.htaccess redirect-collection

Redirect to www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect to non www (generic)

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

Redirect to non www (by host)

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

Redirect all to another domain

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

Redirect domain to another domain

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

Redirect to language selector, if URI is empty

RewriteRule ^$ /de_de/ [R=permanent,L]

Redirect to https

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

Maybe worth a try: if "%{HTTPS} off" or "%{SERVER_PORT} !=443" does not work

RewriteCond %{HTTP:X-Forwarded-Proto} = http
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect to https and www

RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.example.com%{REQUEST_URI} [R=301,L]

Redirect to https and non-www

RewriteEngine on
RewriteCond %{SERVER_PORT} !=443 [OR]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]

Redirect a specific domain to www and https

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

RewriteCond %{SERVER_PORT} !=443
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

Redirect all from old to new directory

RedirectMatch 301 /Old/Dir/.* http://www.example.com/new/dir