LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 09-09-2011, 11:28 PM   #1
decenter
Member
 
Registered: Sep 2011
Distribution: Ubuntu 12.04.4 LTS
Posts: 136

Rep: Reputation: 17
redirect https://www.domain.com to https://domain.com


Hi,

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

Thanks.
 
Old 09-10-2011, 03:45 AM   #2
roberto967
Member
 
Registered: Apr 2011
Distribution: Slackware64-current
Posts: 65

Rep: Reputation: 12
If you have apache/mod_rewrite installed put this in your .htaccess
Code:
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
  RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]
</IfModule>
Otherwise you can use php in this way:

Code:
if ($_SERVER['HTTP_HOST']=='www.domain.com')
	header("Location: https://domain.com".$_SERVER['REQUEST_URI']);

Last edited by roberto967; 09-10-2011 at 03:46 AM.
 
Old 09-10-2011, 06:17 AM   #3
zackwasa
Member
 
Registered: Sep 2011
Posts: 52

Rep: Reputation: Disabled
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 *.yourdomain.com

RMI

Last edited by zackwasa; 01-12-2012 at 01:54 AM.
 
Old 09-10-2011, 06:27 AM   #4
whit3fir3
LQ Newbie
 
Registered: Sep 2011
Posts: 5

Rep: Reputation: Disabled
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 domain.com and www.domain.com. 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.
 
Old 09-13-2011, 11:05 AM   #5
decenter
Member
 
Registered: Sep 2011
Distribution: Ubuntu 12.04.4 LTS
Posts: 136

Original Poster
Rep: Reputation: 17
Ok. Thanks.I will better install ssl for www.domain.com too.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
apache 2.0 https to https redirect struct Linux - Software 1 04-22-2011 06:43 PM
[SOLVED] https and http for one domain name yoachan Linux - Server 4 03-13-2011 07:52 AM
[SOLVED] redirect https non-www Apache rahmad Linux - Server 13 04-20-2010 03:12 AM
Apache https redirect without-www to with-www alitrix Linux - Server 3 07-24-2008 07:11 AM
one domain on 443 and other on 80 but https on 80 domain need to be stopped majid Linux - General 0 08-30-2006 08:24 PM


All times are GMT -5. The time now is 12:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration