0

Good Day.

I'm setting up a mac for local development and have configured dnsmasq.conf with the following:

address=/.dev/127.0.0.1

My wish is to run sites locally by http://client1.ext.dev/index.html which will map to a local folder of /www/sites/client1.ext/htdocs/index.html. Of course the variables here are client# and it's associated ext which could be any normal TLD -- .com, .net, .info, etc.

I've tried every permutation that I could think of, but I can't seem to get the httpd.conf to map correctly (technically my httpd-vhosts.conf file).

<Virtualhost *:80>
  VirtualDocumentRoot /www/sites/%-2+/htdocs
  #ServerName sites.dev 
  ServerAlias *.dev
  UseCanonicalName Off
</Virtualhost>

Using this uri in my browser client1.com.dev/index.html, my log files reads File does not exist: /www/sites/client1.com Why won't the remaining mapping of VirtualDocumentRoot not work? (The "/htdocs" part is not being added.).

Many posts indicate that it should, but the man page (http://goo.gl/Ghff5G) doesn't show any additional directories beyond the %-mapping.

I've also tried RewriteRules within my directives to no avail (and I'm pretty sure I wasn't doing that correctly).

Bonus

If I have a sub-domain, my browser just goes out to OpenDNS (which I have configured to default after my internal IP) and says it can't find sub.client1.com.dev which I'd like to map to /www/sites/sub.client1.com/htdocs.

Thank you!

  • It's a silly question, but does /www/sites/client1.com exist? – larsks Aug 16 '13 at 16:15
  • yes, as does /www/sites/client1.com/htdocs/index.html – dmayo Aug 16 '13 at 16:51
  • Ok, sorta solved. – dmayo Aug 16 '13 at 17:26
  • Ok, sorta solved. http://client1.com.dev still not resolving, so I cp the dir and renamed to http://anything.com.dev -- and it works. Grrr. Still beating head as http://client1.com.dev is not. However, http://client1.com.dev/index.html DOES work (as does http://anyting.com.dev/index.html Ugh. No clue as to why. I don't see any differences anywhere. – dmayo Aug 16 '13 at 17:32
  • Still trying to figure out the sub-domain, so http://sub.client1.com.dev maps to /www/sites/sub.client1.com/htdocs. Any takers? – dmayo Aug 16 '13 at 17:33
0

As you've got a 1:1 mapping you should just be able to use the full URL with;

<Virtualhost *:80>
  VirtualDocumentRoot /www/sites/%0/htdocs
  ServerName %0
  UseCanonicalName Off
</Virtualhost>

The above should also work for subdomains.

I do something similar apart from I just use a .dev TLD in place of the actual live one and also alias to xip.io for devices that don't use my local dnsmasq dns.

# Any .dev folder in ~/Sites
#
<VirtualHost *:80>
    VirtualDocumentRoot "/Users/phunky/Sites/%1.0.%-1.0/public"
    ServerName %-2.0.%-1.0
    ServerAlias %-2.0.%-1.0.*.xip.io
</VirtualHost>

Now if I could figure out how to get subdomains to map to alternative folders within the VirtualDocumentRoot i'd be a very happy man.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.