-   Linux - Server (
-   -   redirect to (

decenter 09-09-2011 10:28 PM

redirect to

I have ssl installed on my site.It works when I browse https:// . But when some one browse , it gives invalid certificate error. So I need to redirect from to Any help is appreciated .


roberto967 09-10-2011 02:45 AM

If you have apache/mod_rewrite installed put this in your .htaccess

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
  RewriteRule ^(.*)$$1 [L,R=301]

Otherwise you can use php in this way:


if ($_SERVER['HTTP_HOST']=='')

zackwasa 09-10-2011 05:17 AM

you will get the certificate warning anyway because the mod_rewrite redirect rules are executed after you hit the certificate for https://

unfortunately there's no workaround for this and the only way is to get a certificate for *


whit3fir3 09-10-2011 05:27 AM

zackwasa is correct that using the rewrite rule will not fix issue as people will still have to connect to the server via HTTPS to get the rewrite rule. There is a way to get more than 1 CN assigned to a single SSL certificate. So for example a single SSL certificate would work for both and I don't remember the process for this off hand, but you will probably have to generate a new key / csr and send that to your signer and have them resign the cert.

decenter 09-13-2011 10:05 AM

Ok. Thanks.I will better install ssl for too.

All times are GMT -5. The time now is 01:01 PM.