Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I would like to use virtual hosting to redirect each domain I have to a folder on my server. So I changed the DNS of my domains in order ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    5

    VirtualHost Apache


    Hi,
    I would like to use virtual hosting to redirect each domain I have to a folder on my server.
    So I changed the DNS of my domains in order to be redirected to my server, and that's working.

    Now I want to set the virtualhost config to reach the relevant folder for all my domains.
    The default configuration of my Gentoo is:
    Code:
    <VirtualHost *:80>
    	ServerName localhost
    	Include /etc/apache2/vhosts.d/default_vhost.include
    	<IfModule mpm_peruser_module>
    		ServerEnvironment apache apache
    	</IfModule>
    </VirtualHost>
    And I've added just after that:
    Code:
    <virtualhost *:80>
    	ServerName mysite.com 
    	ServerAlias www.mysite.com
    	DocumentRoot /home/ovh/www/mysite
    </virtualhost>
    But when I want to reach "mysite", I'm always redirected to the root of my server (that is to say, to /home/ovh/www instead of /home/ovh/www/mysite)
    That's as if what I added couldn't be read... I just don't understand why and what I should do to get it working.

    Can you help me ?

    Thanks a lot.

    PS : I apologize for my poor english... I'm french.

  2. #2
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    you need "name based virtual hosts", google that or search this forum. I know I have helped on several topics about that in this forum, google has good help also.

  3. #3
    Just Joined!
    Join Date
    Aug 2008
    Posts
    5
    Thanks Jledhead.
    I searched google and this forum (all threads having "virtual host" or "virtualhost" in the title), and I found many threads about the issue I deal with.
    I found many threads with no answer like this one and some others with many answers but not explaining how to fix the problem (like this one).
    But absolutly none of them explain what to do if your configuration always chose the default virtual host (the first), instead of the one matching to the hostname typed.

    So the issue is that when i type 'mysite.com' in the URL bar, I'm driven to the path of my default virtual host instead of the path of the virtual host with the line
    Code:
    ServerName mysite.com
    If someone having already dealt with that could help, I'm sure that it would help more than one person.

    Thanks a lot

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    Quote Originally Posted by Gorion View Post
    Thanks Jledhead.
    I searched google and this forum (all threads having "virtual host" or "virtualhost" in the title), and I found many threads about the issue I deal with.
    so did you read my post. i didn't say search for virtual host, I said search for name based virtual hosts (its different, thats why I said it)
    name based virtual host - Google Search

    http://www.linuxforums.org/forum/sea...archid=1291289

  6. #5
    Just Joined!
    Join Date
    Aug 2008
    Posts
    5
    Quote Originally Posted by jledhead View Post
    so did you read my post. i didn't say search for virtual host, I said search for name based virtual hosts (its different, thats why I said it)
    I did it too... That was my redirection that was not set correctly. I had not chosen to redirect the hostname by changing DNS (there was an other choice in my OVH manager).
    So the configuration above was OK.. So if you're reading this post and if you don't understand why your configuration doesn't redirect your websites in your directories proprely (and if you have checked that your configuration files are correct), have a look to your DNS configuration ! Just check that the target of the field "A" is the IP adress of the server you want to redirect hostnames to.

    For OVH users : Be careful to change the DNS of your hostnames, and not to chose the option "Redirect website", for this one will just build a page with a frame containing the home page of the root of your server.

    Once again, I apologize for my 'frenglish'.

  7. #6
    Just Joined!
    Join Date
    Sep 2008
    Posts
    3
    This is the Virtual-Domain-Conf for my Home-Server (Windows, XAMPP):
    Code:
    NameVirtualHost 127.0.0.1
    
    # Deninition of Virtual-Domain 1 (www.domain.tst):
    <VirtualHost www.domain.tst:80>
      ServerName www.domain.tst
      DocumentRoot "Drive:/path/to/htdocs"
    <Directory "Drive:/path/to/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    </VirtualHost>
    
    # Deninition of Virtual-Domain 2 (www.domain2.tst):
    ... (same as above with dofferent domain-name
    On Windows add also in &#37;WINDOWS%\system32\drivers\etc\hosts the following:
    Code:
    127.0.0.1	www.domain.tst
    Since this is a Home-Server i don't looked at security and several options in the configuration of Apache.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •