Steps
- sudo mkdir -p /var/www/rex.com/
- sudo chown -R ubuntu:www-data /var/www/rex.com/
- sudo chmod -R 755 /var/www/
- cd /etc/apache2/sites-available/
sudo cp 000-default.conf rex.com.conf
sudo nano rex.com.conf - sudo a2ensite rex.com.conf
- sudo service apache2 restart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<VirtualHost *:80> ServerName lab.com ServerAlias www.lab.com ServerAdmin root@localhost DocumentRoot "/var/www/lab" <Directory /> AllowOverride none Require all denied </Directory> <Directory "/var/www/lab"> Options Indexes FollowSymLinks AllowOverride all Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/lab-error.log CustomLog ${APACHE_LOG_DIR}/lab-access.log combined RewriteEngine on RewriteCond %{SERVER_NAME} = www.lab.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] </VirtualHost> |
Reference: