Reputation: 251
Let's say we have,
Old Domain : http://www.olddomain.com
New Domain : https://www.newdomain.org
Here's my .htaccess file data :
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
RewriteRule ^/?$ "https\:\/\/www\.newdomain\.org\/" [R=301,L]
Sometimes while redirection, browsers are displaying the Security error such that it is untrusted.
Now,
Upvotes: 4
Views: 4006
Reputation: 786091
Change the order of your rules and clear your browser cache before you test it:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^ https://www.newdomain.org%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.newdomain.org%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Upvotes: 3