Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I made this many times but now it wont work. I have configure apache to work with different ports, and work with different ip and this same thing also i have made work ... iv configured bind as my local dns and when i go to my host for example ( i have linux server CentOS named vipc ) when i go the http:// vircent .. it opens the page that iv put in /var/www/page1/index.html. Now what im trying to do is, when i go to http:// vircent/site1 - to go and open the index.html from page1 directory. But also i want when i go to htt:// vircent/site2 to open the index.html from page2 directory.

This is what i have for now and i dont know way it wont work

    NameVirtualHost *:80
    <VirtualHost *:80>
    ServerName      vircent
    DocumentRoot    /var/www/page1
    </VirtualHost>

    <VirtualHost *:80>
    ServerName      vircent
    DocumentRoot    /var/www/page2
    </VirtualHost>
share|improve this question

1 Answer 1

up vote 3 down vote accepted

You're trying to do two different things at once.

If you want http://vircent/site1 and http://vircent/site2 to go to the two different sites, you need to set up a single site ("vircent") with those two locations (the easiest way is just by physically moving the directories to the appropriate places, eg in this case by having the DocumentRoot point to /var/www, in which case http://vircent/page1 and http://vircent/page2 will work like you want them to).

Name-based virtual hosts are for having two different names, eg vircent1 and vircent2 -- on a side note, it's often best to use a fully qualified domain name for these sorts of things. So, you might change your httpd.conf to read something like

NameVirtualHost *:80
<VirtualHost *:80>
ServerName      vircent1
DocumentRoot    /var/www/page1
</VirtualHost>

<VirtualHost *:80>
ServerName      vircent2
DocumentRoot    /var/www/page2
</VirtualHost>

(And make the appropriate changes in BIND)

As it is, you have two different virtual hosts with the same ServerNames, which means only the first one is getting served out.

share|improve this answer
1  
I think i get it ... you just have to point to the directory and the access from the browser will be the name of the directory ... http:// vircent/<directory_name> ... this was my confusion thank you ... –  IvanAK Jan 7 at 21:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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