server {
listen 80;
server_name example.in;
return 301 http://example.com$request_uri;
}
RewriteCond %{HTTP_HOST} ^example.in [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301,NC]
server {
listen 443;
server_name example.com;
return 301 http://example.com$request_uri;
}
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301,NC]
server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
server {
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]
NOTE!: You can directly test your .htaccess rules at http://htaccess.madewithlove.be/