htaccess redirect https domainA to domainB

Mongoose42
Mongoose42 used Ask the Experts™
on
Hello, I am trying to redirect domainA to domainB via the following entry in my .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainA.com
RewriteRule ^(.*) http://domainB.com/en/ [P]

Open in new window


This works quite well as I thought it did but it does not when a person types into the url https://domainA.com 
Then the customer is not redirected to domainB.com.

What am I missing here ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
btanExec Consultant
Distinguished Expert 2018

Commented:
Maybe something such as where example.com can be your domainA and www.example.com is your domainB. The difference is only on the use of "$ [NC]" meaning appended and no case and for [R=301,L], I see that you use [P] for mod_proxy, maybe we can stick with it..

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

ref - flags https://httpd.apache.org/docs/2.4/rewrite/flags.html

Author

Commented:
Thanks for the suggestion but it is not working.  Whenever you surf to https://ourolddomain.com, you are not redirected as if you were to surf to http://ourolddomain.com and then being redirected to http://ournewdomain.com
Exec Consultant
Distinguished Expert 2018
Commented:
You then need to add probably this too e.g.
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
https://sites.google.com/site/onlyvalidation/page/301-redirect-https-to-http-on-apache-server
Also do ensure you have the server SSL provisiined in the web server.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial