Forum Moderators: phranque

Message Too Old, No Replies

Virtual Host Configuration

www domain and non-www domain in Apache2

         

elvang

6:53 am on Apr 21, 2022 (gmt 0)

Top Contributors Of The Month



Hi, I am trying to create a virtual host with apache.
My primary domain is www.example.com. And i am thinking to redirect example.com's traffic(non-www domain) to this www domain.

1- In my /etc/apache2/sites-available/example.com.conf file should i write www domain for server name and non-www domain for server allias? Or should i write the opposite?

2- Beside this i have DNS records for www domain but i havent created any dns records for non-www domain yet. Should i create dns records for non-www domain not to have problem during the installation of ssl certificate or in other fields?

Thank you.

phranque

7:31 am on Apr 21, 2022 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



should i write www domain for server name and non-www domain for server allias?

yes - i would do it this way
Should i create dns records for non-www domain not to have problem during the installation of ssl certificate or in other fields?

you should do it so that potential visitors making non-www requests will be able to resolve the non-www hostname's IP address prior to sending the request to your server.

elvang

7:24 am on Apr 22, 2022 (gmt 0)

Top Contributors Of The Month



thank you phranque