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'm having issues with redirecting a domain name to a specific folder on my server. I'm reading the istructions from here:

These are my configuration lines:

#This is the default Apache2 configuration lines
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www

#This is what I've added
<VirtualHost *:80>
    DocumentRoot /var/www/astudio/sites/mywebsite
    ServerName www.mywebsite.com
</VirtualHost>

However it doesn't work.. the domain just not forward the user to my website.. is there something else I have to configure ?

share|improve this question
    
You tried to include a link to the instructions you're following, but the link is missing. –  unixguy Oct 7 '10 at 15:29
    
Patrick, this looks like a duplicate of your question at serverfault.com/questions/186146/… . I don't know what the protocol is here for asking the same question multiple times, but it might not be the most efficient way to get the answer! –  MadHatter Oct 8 '10 at 8:28
    
@MadHatter ok, anyway I cannot anymore delete it –  Patrick Oct 8 '10 at 8:53

3 Answers 3

up vote 3 down vote accepted

Try this (presuming that www.mywebsite.com resolves to the ip address of your web server):

#This is the default Apache2 configuration lines
<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/astudio/sites/mywebsite
   ServerName www.mywebsite.com
</VirtualHost>
share|improve this answer

Very little information to work with. Anyway...

Can you connect to the server and get the default welcome page? Do you connect using the server name or the IP address? If you use the IP address, the you will get the default page. Did you reload the configuration?

If you cannot connect, do you have the correct IP address? Is it a firewall/iptables issue? If apache listening on eth0 or only on the loopback interface?

====== EDIT

If you connect using the IP address, you get the default page, no the one you want, because the Host: header in the HTTP request does not match with the ServerName defined in your VirtualHost. You have to access your website specifically with www.mywebsite.com to access your pages (You can add aliases, though).

If you cannot connect with the name, then you have a DNS issue. A quick solution is to add the hostname and IP address to your hosts file. In Linux is /etc/hosts, in Windows it is somewhere in \windows\system32\... (I forget where exactly)

====== EDIT2

If you access a web site with its IP address, the Host: header will contain the IP address, e.g. Host: 1.2.3.4:80. I have not tried it but you can try add the IP address to your VirtualHost as a ServerAlias. I assume you have a dedicated IP address.

share|improve this answer
    
I connect to the server using the IP address. No firewall, I dunno if apache is listening on eth0 or only on the loopback interface but it works correctly. –  Patrick Oct 8 '10 at 7:00
    
Added some more info in the response –  Dan Andreatta Oct 8 '10 at 7:31
    
Is there something I can do from Apache, or is something to solve in control panel of my hosting service or by contacting their support ? –  Patrick Oct 8 '10 at 8:18
    
Added more info –  Dan Andreatta Oct 8 '10 at 9:39

Assuming you want to do name-based virtual hosting, do you have a NameVirtualHost *:80 directive?

Also, do you have any other VirtualHost sections elsewhere in your configuration that might be interfering with this one?

share|improve this answer

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.