htaccess redirect https domainA to domainB

Hello, I am trying to redirect domainA to domainB via the following entry in my .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*) [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 
Then the customer is not redirected to

What am I missing here ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

btanExec ConsultantCommented:
Maybe something such as where can be your domainA and 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 ^(.*)$$1 [R=301,L]

ref - flags
Mongoose42Author Commented:
Thanks for the suggestion but it is not working.  Whenever you surf to, you are not redirected as if you were to surf to and then being redirected to
btanExec ConsultantCommented:
You then need to add probably this too e.g.
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
Also do ensure you have the server SSL provisiined in the web server.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.