Newbie virtual hosts problem

Discussion in 'Apache' started by gezginrocker, Feb 14, 2012.

  1. #1
    hello,

    I have installed Scientific linux and having trouble with virtual hosts.

    I set my hostname as "lunar.taylandgezirehberi.com"

    and those are my apache settings:

    ----------------------------------------------------------------------

    ServerName lunar.taylandgezirehberi.com

    NameVirtualHost *:80

    <VirtualHost *:80>
    DocumentRoot /home/can/public_html/taylandgezi
    ServerName taylandgezirehberi.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /home/can/public_html/taylandvilla
    ServerName taylandvilla.com
    </VirtualHost>
    ----------------------------------------------------------------------

    www.taylandgezirehberi.com is working fine.

    but both www.taylandvilla.com/taylandvilla.com are redirecting to www.taylandgezirehberi.com

    what am I doing wrong here?
     
    gezginrocker, Feb 14, 2012 IP
  2. gezginrocker

    gezginrocker Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #2
    found a solution, I added a second virtual host with redirect, now it seems to be working fine.

    <VirtualHost *:80>
    DocumentRoot /home/can/public_html/taylandvilla
    ServerName www.taylandvilla.com
    </VirtualHost>

    <VirtualHost *:80>
    DocumentRoot /home/can/public_html/taylandvilla
    ServerName taylandvilla.com
    redirect permanent / http://www.taylandvilla.com/
    </VirtualHost>
     
    gezginrocker, Feb 14, 2012 IP
  3. BigTim3

    BigTim3 Guest

    Messages:
    266
    Likes Received:
    1
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Have you looked into using ServerAlias?
     
    BigTim3, Feb 16, 2012 IP
  4. gezginrocker

    gezginrocker Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #4
    yes thanks someone told me about that. now I'm using ServerAlias and everything is fine.
     
    gezginrocker, Feb 17, 2012 IP