I have the following httpd configuration to allow subdomains and to redirect www url to non-www url:
ServerName example.com:80 NameVirtualHost *:80 <VirtualHost *:80> ServerName example.com ServerAlias (a([c-g]|i|[l-o]|[q-u]|w|x|z)|z(a|m|w)).example.com </VirtualHost> <VirtualHost *:80> ServerName www.example.com Redirect permanent / http://example.com/ </VirtualHost>
I want to test that these settings are valid. I thought initially that placing those urls in the hosts file would enable me to do that. But it doesn't seem so as any subdomains that does not match ServerAlias in virtual host can still run. So can this be done without a DNS?