By arturofm
I can access to the web like: example.com but if I try www.example.com , it says: page not found or something like that. I’m building right now a multi site with apache virtual host and I can’t find how to do it in my new domain, any help? :)
Thanks
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!
Add ServerAlias www.example.com to your virtual host file to listen on www.
For example:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Also you need to create a DNS record to your (www) subdomain.
For intance: example.com is your domain (zone) and www.example.com is your subdomain such as api.example.com or w3.example.com, but the commonly used subdomain is www by convention.
Let’s say you have a A record in your DNS for your domain like this
@ A 192.168.0.1
People can reach your site just typing http://example.com in the URL bar of the browser. Now if you need to expose your site as http://www.example.com you can do this in several ways, these are two of them.
www A 192.168.0.1
www CNAME @
I would prefer the option 2 but it’s your choice.
Hope this helps you. :)
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.