LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-17-2014, 08:28 AM   #1
crackconfig
LQ Newbie
 
Registered: Jul 2010
Posts: 15

Rep: Reputation: 0
SSL with www not working


Hi all..

my domain is running quite good on https://domain.com

but i also want to make the URL https://www.domain.com work.
I tried some rewrite rule in htaccess ie -

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]

didnt work for me..

pls help.. Thanks..
 
Old 04-17-2014, 09:07 AM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Unless you have a wildcard certificate (e.g. '*.domain.com') you must purchase two SSL certificates. One for domain.com and one for www.domain.com. There's also free alternatives to SSL certificates such as StartCom SSL. You would need a virtualhost for www.domain.com.

In practice, you should order your virtualhosts alphabetically so that your most important certificate is served by default. e.g.

Code:
#listing of /etc/httpd/conf.d/
00-init.conf
01-errorcodes.conf
1000-domain.com.conf
1001-www.domain.com.conf
The reason why you want to alphabetically order your configuration files is because apache parses them alphabetically and will serve the first SSL certificate it encounters upon first connection when a browser is not using Server Name Indication (SNI). SNI is what allows apache to serve SSL virtual hosting for different domains on the same port.

Once you have the virtualhost and certificate installed your redirection should be relatively smooth for browsers that support SNI (which is most modern browsers).
 
  


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
Setup sample SSL subdomain site but keeps going to www j.smith1981 Linux - Server 14 02-03-2012 05:14 AM
Postfix TLS working fine but SSL over port 25 not working bob808 Linux - Server 10 07-25-2009 09:20 PM
secure. vs www. ssl apache config hank43 Linux - Networking 4 08-09-2006 10:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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

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
Open Source Consulting | Domain Registration