LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Apache Virtual Hosts Problem (https://www.linuxquestions.org/questions/linux-newbie-8/apache-virtual-hosts-problem-929302/)

gezginrocker 02-14-2012 10:23 AM

Apache Virtual Hosts Problem
 
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?

Cedrik 02-14-2012 10:32 AM

Did you add some lines in /etc/hosts like
Code:

<your ip> taylandgezirehberi.com
<your ip> taylandvilla.com

(edit)
Sorry, just realized you want these sites accessible from internet :/

Maybe see DNS settings then

gezginrocker 02-14-2012 10:49 AM

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>

Cedrik 02-14-2012 12:56 PM

For this sort of redirect, there is also ServerAlias directive

gezginrocker 02-14-2012 01:59 PM

is it better to use ServerAlias directive?

if so, can you give me an example usage please?

thanks

Cedrik 02-14-2012 02:31 PM

Same effect as above but with just one VirtualHost directive
Code:

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


gezginrocker 02-14-2012 03:32 PM

thank you very much Cedrik, it works perfectly. :)

have a nice day...


All times are GMT -5. The time now is 06:42 PM.