htaccess redirect https domainA to domainB

Mongoose42 used Ask the Experts™
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 ?
Watch Question

Do more with

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

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


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
Exec Consultant
Distinguished Expert 2018
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.

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