My website's two major sections can be accessed using:
www.example.comfor general content
laptop.example.comfor more specific content
The laptop section is ready and deployed. User can access it directly. Also, search engines have started crawling and indexing it.
BUT, the general content is not ready; it will not be for few months.
As of now, there is no document root or files in the server for www and there is no virtual host tag for it.
Content of httpd.conf:
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /path/to/website/subdomain/root ServerName example.com ServerAlias laptop.example.com <Directory /path/to/website/subdomain/root> AllowOverride All Allow from all </Directory> </VirtualHost>
There is no other virtual host tag in there.
In my domain registrar control panel, I have added an A Record for the subdomain
laptop and pointed it to my server IP. There are two other entries -
www both pointing at my IP. I am unable to edit/delete the www entry.
I thought that is all that is needed to prevent access to
www. But it is not working!
When users type
www.example.com, they are taken to
laptop.example.com. I don't want this to happen. Just some default browser error message like Server not found or Page not found should be shown.
How can I achive this?
One Solution: I added the following to end of httpd.conf
<VirtualHost *:80> ServerName www.example.com </VirtualHost>
I don't think this is an elegant method. Still waiting for a better/proper way to do it.