Question

I'm using dnsmasq for my local development environment but I want to use multiple TLDs, currently my dnsmasq.conf file looks like this

address=/.dev/127.0.0.1

& apache http-vhosts.conf looks like this

<Virtualhost *:80>
  UseCanonicalName Off
  VirtualDocumentRoot "/Users/<username>/Sites/dev/%1"
  ServerAlias *.gabri
  LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
  ErrorLog "/Users/<username>/Sites/dev/vhosts-error_log"
</VirtualHost>

and this configuration works, just create a new folder called 'client' for example then you can access it from client.dev.

Now I want to add another TLD let's say .test how can this be done? I guess in Apache it's the same but replacing dev with test, what about dnsmasq?

Was it helpful?

Solution

in your dnsmasq.conf add:

address=/.test/127.0.0.1

in your http-vhosts.conf add:

<Virtualhost *:80>
  UseCanonicalName Off
  VirtualDocumentRoot "/Users/<username>/Sites/test/%1"
  ServerAlias *.test
</VirtualHost>

create file "/etc/resolvers/test" with content:

nameserver 127.0.0.1

More info about the resolver thing. You could also edit the "/etc/hosts" file. I prefer the /etc/resolvers solution.

Do not forget to flush DNS caches afterwards.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top