Subdomain in localhost won't work

Hello, I always get 500 configuration error every time I try to put the Virtual Host into my .httaccess. I’m trying to achieve subdomains on my local machine.

Something like

Here is the code that I’m trying to work with. I’ve got it from

   ServerName blogs.localhost
   DocumentRoot "C:/dev/www/blogs"

I keep getting 500 configuration error even after this.

Did you try it this way?

<VirtualHost *:80>

Yup. I’ve tried both. I keep getting the same 500 error.

I don’t know why I missed that the first time. I guess I wasn’t expecting it.

I believe that VirtualHost directives may only be placed inside server configuration files, not inside per directory htaccess files.

Ok thanks. I got it to work. I had to use my server configuration in my Apache folder. Thanks a lot. I thought it was an .htaccess command.

For others,

Creating a VirtualHost on a test server (yes, a subdomain is another VirtualHost), you need to edit TWO files: httpd-vhosts.conf and hosts (no extension).

CD picked up the port which is required (I prefer to specify but both files are well commented. Copy an entry and edit it for your VirtualHost then save.

WinDoze users:

  1. WinDoze protects a number of directories so (1) don’t install Apache in Program Files.

  2. The hosts file exists in C:\Windows\system32\drivers\etc as hosts. Open a text editor (RUN AS ADMINISTRATOR) then open the hosts file, edit, and save. If you don’t do this as “Administrator,” WinDoze will NOT save your edits.