By grooversss
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 %{SERVER_PORT} !^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/public_html
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?
Domain that is was talking about is https://smmhouse.com Subdomain http://api.smmhouse.com http://support.smmhouse.com
Thank You for all your help in advance
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Replace
<VirtualHost _default_:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
with
<VirtualHost _default_:80>
ServerAdmin admin@domain.com
ServerName domain.com
ServerAlias www.domain.com
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>
and restart Apache: sudo service apache2 restart. Does that fix it?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.