Problem with Virtualhosts

Discussion in 'Apache' started by beniwtv, May 3, 2006.

  1. #1
    Hi. I'm having trouble with this virtualhost configuration:

    <VirtualHost *:80>
    DocumentRoot /home/xxx/rewrite/www
    ServerName benito.xxx.com
    ServerAlias *.benito.xxx.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /home/xxx/www/beni
    ServerName xxx.com
    ServerAlias *.xxx.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /home/xxx/www/beni
    ServerName info.xxx.com
    ServerAlias *.info.xxx.com
    </VirtualHost>

    Let me explain: both xxx.com and info.xxx.com are sites that are located in the same directory, in fact, they're the same site. benito.xxx.com is located in another directory with a file called content.php and .htaccess in it, that, basically do the following: you enter benito.xxx.com/Directory/foo/bar and it will redirect to content.php?Path=foo/bar. This works fine.

    But now, if I am trying to access the other sites on certain directories, for example, info.xxx.com, apache will use benito.xxx.com instead. I don't know why. Hint: I am using Apache 2.

    Thanks for any help,
    beni
     
    beniwtv, May 3, 2006 IP
  2. theblight

    theblight Peon

    Messages:
    246
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try to check your DNS configuration and try to clear your browser cache and let me know the results

    Hope it Helps
     
    theblight, May 3, 2006 IP
  3. beniwtv

    beniwtv Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I've found out what my problem is. In xxx.com and info.xxx.com some pages use the php file_get_contents on localhost. Since Apache don't knows about localhost, it uses the first directive. As a result, the pages won't work because the files aren't there (remember that we have different DocumentRoots).

    So, what I need now is to tell apache that localhost goes to the directory from xxx.com or info.xxx.com. How can I do that?

    Thanks.
     
    beniwtv, May 3, 2006 IP
  4. theblight

    theblight Peon

    Messages:
    246
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <VirtualHost 127.0.0.1:80>
    ......
    </VirtualHost>

    or

    <VirtualHost localhost:80>
    ......
    </VirtualHost>
     
    theblight, May 3, 2006 IP
  5. beniwtv

    beniwtv Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, thank you! I've corrected this problem.
     
    beniwtv, May 3, 2006 IP