-1

my website hosted on ec2 - AWS. I want to add www in my website. Also my website has ssl. I am not able to add www in my website. I want my website full domain should be start with https://www.

I installed ubantu.

  • Hi Yash. Could you provide more details as to your current set up of your EC2 instance, including configuration? Adding "www" is an example of adding a subdomain. A post like this may be able to help you: https://stackoverflow.com/questions/4203580/creating-subdomains-in-amazon-ec2 – tjheslin1 Feb 08 '20 at 12:18
  • ec2 instance with ubuntu machine. for website node react and mongodb are used – Yash Pratap Feb 10 '20 at 07:54

1 Answers1

0

First, connect to your ec2 instance using ssh After connect successfully go to your root directory using sudo su - After that run sudo nano /etc/apache2/sites-available/000-default.conf to open your config file. then in your vi editor you have to write below code

ServerName yourdomain.com
ServerAlias www.yourdomain.com

<Directory /var/www/html/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

save the file. And restart your apache server using service apache2 restart.

Hope this will help you.