I have a strange problem with my domains in search engines:
I am owning several domains, let's say:
example.com
example.net
example.org
All domains are pointing to my server, that's why I added a redirect on top of the httpd.conf file to prevent doublicated content:
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
It's working well for the users.
Since I got a ssl-certificate for the .com domain, I am redirecting all users to the https version:
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
Working also well for the users.
Now the strange problem: For some reason, sometimes search engines are listing https://example.net/apage.php and since I got no ssl-certificate for the .net (and .org) domain, when visitors are clickling these results in search engines, they will get a browser warning that the connection to the website is not secure. This is very confusing and I couldn't find a way to redirect visitors to the correct .com domain before the browser warning appears.
Do you got an idea to solve this problem with a mod_rewrite condition or any work around?