0

I have an Apache2 configuration under Cygwin that I'm in the process of setting up some virtual hosts for. The problem I am encountering is that regardless of the address entered, they all appear to be pointing to the same directory - which happens to be one of those virtual hosts.

My httpd-vhosts.conf is as follows ( Comments stripped ):

NameVirtualHost *:80 <VirtualHost sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/sg.agpvideo.com" ServerName sg.agpvideo.com </VirtualHost> <VirtualHost rest.sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/rest.agpvideo.com/laravel/public" ServerName rest.sg.agpvideo.com </VirtualHost> <VirtualHost site1.sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/site1.sg.agpvideo.com" ServerName site1.sg.agpvideo.com </VirtualHost> <VirtualHost site2.sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/site2.sg.agpvideo.com" ServerName site2.sg.agpvideo.com </VirtualHost> <VirtualHost agency1.sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/agency1.sg.agpvideo.com" ServerName agency1.sg.agpvideo.com </VirtualHost> <VirtualHost agency2.sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/agency2.sg.agpvideo.com" ServerName agency2.sg.agpvideo.com </VirtualHost> 

And it seems that all of them are pointing to the first in the list ( sg.agpvideo.com ). Does anyone have a simple explanation? If my httpd.conf is necessary I can post it.

Edit: In toiling with this trying to get it to work, a couple of them are pointing to the actual server's document root... Oddly enough.

1 Answer 1

1

I'm not sure if this will completely solve your problem, but it might give you enough to figure it out. My setup (which works on my local Windows machine) is as follows. For each one of your subdomains, try replacing this:

<VirtualHost sg.agpvideo.com:80> DocumentRoot "/home/user/public_html/sg.agpvideo.com" ServerName sg.agpvideo.com </VirtualHost> 

with this in your httpd.conf file:

<VirtualHost *:80> ServerName sg.agpvideo.com DocumentRoot "C:/xampp/htdocs/(whatever your project folder's name is)" <Directory "C:/xampp/htdocs/(whatever your project folder's name is)"> Options All AllowOverride All Require all granted </Directory> </VirtualHost> 

and then, add an entry to your 'hosts' TCP/IP file located in your Windows folder (mine is 'C:\Windows\System32\drivers\etc\hosts'), add this:

127.0.0.1 sg.agpvideo.com rest.sg.agpvideo.com site1.sg.agpvideo.com (and so on) 

If you need help with a production server setup, let me know and I can give you that setup as well.

Sign up to request clarification or add additional context in comments.

4 Comments

You may have just answered the question... I'm binding on DNS name rather than IP... brilliant.
Bah. Maybe not. Same result. I'll keep toiling. Thanks for the comments.
I should have pointed out that in each of the subsequent httpd.conf entries, make sure to replace the "ServerName sg.agpvideo.com" (after that first one) with "ServerName rest.sg.agpvideo.com" and then keep changing each one to match up. Also, make sure you entered these into the httpd.conf file and not the httpd-vhosts.conf file. It took me a lot of trial-and-error when I first got mine set up.
One other thought is make sure these links are going to your project's different folders C:/xampp/htdocs/(whatever your project folder's name is) within the root directory

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.