LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 09-18-2006, 07:30 PM   #1
paddyjoy
Member
 
Registered: Apr 2005
Location: Sydney
Distribution: FC5
Posts: 174

Rep: Reputation: 30
apache virtual host help?


Hi,

I'm trying to set up some virtual hosts on apache, currently I have it working with http://mydomain.com but not with http://www.mydomain.com. Does anyone have any idea why this could be causing a problem?

I presume I need two virtual hosts, one for mydomain.com and one for www.mydomain.com?

Code:
<VirtualHost mydomain.com:80>
DocumentRoot /home/mydomain.com/html
SuexecUserGroup "#500" "#500"
ErrorLog /var/www/error/error_log
CustomLog /var/www/error/access_log common
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory /home/mydomain.com/html>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost www.mydomain.com:80>
DocumentRoot /home/mydomain.com/html
SuexecUserGroup "#500" "#500"
ErrorLog /var/www/error/error_log
CustomLog /var/www/error/access_log common
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory /home/mydomain.com/html>
allow from all
Options +Indexes
</Directory>
</VirtualHost>
 
Old 09-18-2006, 08:48 PM   #2
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,189

Rep: Reputation: 49
thats a dns setting problem. check with your domain name settings.
 
Old 09-19-2006, 04:45 AM   #3
paddyjoy
Member
 
Registered: Apr 2005
Location: Sydney
Distribution: FC5
Posts: 174

Original Poster
Rep: Reputation: 30
dns settings seem to be fine, both mydomain.com and www.mydomain.com point to the correct IP address. Any other ideas?

Thanks,
Paddy
 
Old 09-19-2006, 06:38 AM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
You don't necessarily need to setup two virtual hosts, just add the ServerAlias option in your config...


ServerAlias www.mydomain.com

Of if you want anything typed before the domain, a common way to do this would be:

ServerAlias *.mydomain.com
 
Old 09-19-2006, 06:49 AM   #5
paddyjoy
Member
 
Registered: Apr 2005
Location: Sydney
Distribution: FC5
Posts: 174

Original Poster
Rep: Reputation: 30
Finally got it working, firefox had cached my index.php files for each domain from earlier today when my httpd.conf file was incorrect. That's why it appeared I was getting the wrong site, cleared the cache and everything is fine now!

Thanks for the tip about Server Alias.

Paddy
 
  


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 and virtual host voip_tech_2004 Red Hat 1 04-12-2006 12:36 PM
Apache 2.0 Virtual Host? w0lfeyes Linux - Networking 1 05-03-2004 04:09 PM
apache and virtual host diverge Linux - Networking 2 01-11-2004 03:45 AM
Virtual host and apache Samspeed Linux - General 8 08-06-2003 08:41 AM
apache virtual host mimi Linux - General 1 04-06-2002 06:11 AM


All times are GMT -5. The time now is 06:49 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration