Ubuntu 14.04, apache2 . HTTPS,Domain,Subdomain

September 27, 2014 1.8k views

Hello

I have created my ubuntu server, bought ssl certificate, installed it on server.

And after there was few difficulties
When i've typed in browser my domain Without https it showed me blank page than i have found tutorial about how to redirect http to https and i have added to default-ssl.conf this

<VirtualHost _default_:80>
RewriteEngine on
ReWriteCond %{SERVERPORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP
HOST}/$1 [NC,R,L]
</VirtualHost>
<VirtualHost _default_:443>
ServerAdmin admin@domain.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/publichtml
RewriteEngine on
RewriteCond %{HTTP
HOST} !^(www.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]

And now everything works perfect, except one, i have few subdomains
api.domain.com and support.domain.com , when i type them they automatically redirect to https(but they should be http) and showing me mine main page of domain.com

How to do it right?

Thank You for all your help in advance

2 Answers

Fixed

If anyone interested
Just added in the same config file this

<VirtualHost _default_:80>
ServerAdmin admin@domain.com
ServerName api.smmhouse.com
ServerAlias www.api.domain.com
DocumentRoot /var/www/domain.com/publichtml/api
</VirtualHost>
<VirtualHost _default
:80>
ServerAdmin admin@domain.com
ServerName support.domain.com
ServerAlias www.support.domain.com
DocumentRoot /var/www/domain.com/public_html/Support
</VirtualHost>

Fixed

If anyone interested
Just added in the same config file this

<VirtualHost _default_:80>
ServerAdmin admin@domain.com
ServerName api.domain.com
ServerAlias www.api.domain.com
DocumentRoot /var/www/domain.com/publichtml/api
</VirtualHost>
<VirtualHost _default
:80>
ServerAdmin admin@domain.com
ServerName support.domain.com
ServerAlias www.support.domain.com
DocumentRoot /var/www/domain.com/public_html/Support
</VirtualHost>

Have another answer? Share your knowledge.