LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2012, 11:23 AM   #1
gezginrocker
LQ Newbie
 
Registered: Feb 2012
Posts: 16

Rep: Reputation: Disabled
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?
 
Old 02-14-2012, 11:32 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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

Last edited by Cedrik; 02-14-2012 at 11:34 AM.
 
Old 02-14-2012, 11:49 AM   #3
gezginrocker
LQ Newbie
 
Registered: Feb 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
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>

Last edited by gezginrocker; 02-14-2012 at 12:05 PM. Reason: solved
 
Old 02-14-2012, 01:56 PM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
For this sort of redirect, there is also ServerAlias directive
 
Old 02-14-2012, 02:59 PM   #5
gezginrocker
LQ Newbie
 
Registered: Feb 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
is it better to use ServerAlias directive?

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

thanks
 
Old 02-14-2012, 03:31 PM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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>
 
Old 02-14-2012, 04:32 PM   #7
gezginrocker
LQ Newbie
 
Registered: Feb 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
thank you very much Cedrik, it works perfectly.

have a nice day...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache problem: all virtual hosts point to same document root jsepia Linux - Server 8 06-06-2010 04:38 PM
Apache 2.2 Two Virtual Hosts with same DocumentRoot problem Sysop1911 Linux - Server 1 05-26-2009 09:16 PM
Apache virtual hosts problem alienDog Slackware 9 01-30-2008 01:54 PM
Apache virtual hosts and mod_rewrite problem Gyper Debian 3 08-01-2006 12:22 AM
Problem with Apache Virtual Hosts jaberwooky Linux - Software 4 09-23-2003 02:37 PM


All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration