Test subdomain cookie writing locally

Tag: apache , localhost , subdomain Author: wenchaoyl21 Date: 2013-09-30

I am on Windows 7 and am using Apache for my web server.

I want to set up my local environment so that I can test out the following functionality:

  1. A website on a subdomain (like my.cat.com) writes to a cookie at the .cat.com level
  2. A website on a root domain (like cat.com) reads from the same cookie at the .cat.com level

This is what I have done so far:

Added this to my Windows hosts file:

127.0.0.1   my.cat

127.0.0.1   your.cat

127.0.0.1   cat

Added this to my httpd-vhosts.conf file:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\moo"
ServerName my.cat
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\quote"
ServerName your.cat
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs"
ServerName cat
</VirtualHost>

When I try to access http://cat there's no problem, but if I try to access http://your.cat or http://my.cat then I get an error in my browser saying 'The Web site cannot be found'

I can't find anything in the Apache logs and if I ping or tracert the URLs they resolve to 127.0.0.1

Any idea why Apache doesn't seem to want to pick up the requests?