LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 05-20-2008, 06:45 PM   #1
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
subdomain redirection problem with virtualhost


Hello,

I have two domain names, domain1.tld, and domain2.tld. In DNS, both have A records pointing to the same ip address, 33.44.55.66. www.domain1.tld and www.domain2.tld are CNAME aliases for their respective domains.

My httpd.conf has the following:
Code:
NameVirtualHost *:80
<VirtualHost *:80>
        DocumentRoot /home/domain1/www
        ServerName domain1.tld
        ServerAlias *.domain1.tld domain1.tld
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /home/domain2/www
    ServerName domain2.tld
    ServerAlias *.domain2.tld domain2.tld
    <Directory /home/domain2/www>
        AllowOverride all
    </Directory>
    AccessFileName     .htaccess
</VirtualHost>

when i visit www.domain1.tld, everything is fine. However, when I visit www.domain2.tld, it is redirected to domain2.tld instead of maintaining the 'www' portion. What could be causing this?

Thanks,
Jameson

Last edited by jhwilliams; 05-20-2008 at 06:45 PM. Reason: forgot code tags
 
Old 05-20-2008, 11:46 PM   #2
jcvlz
LQ Newbie
 
Registered: May 2008
Posts: 14

Rep: Reputation: 0
My first thought is that the ServerName for domain2 is "domain2.tld" and not "www.domain2.tld". In other words, you're *telling* the server that the name of the virtual host does not have a host name. Although, depending on what the rest of your httpd.conf, other configuration files, and servered pages contain - you may also want to look at what other directives are being given to the server (e.g. mod_rewrite). Oh, and take a look at the docs regarding AllowOverride - setting it to "All" could give you some headaches if you're not the only one with write permissions to that documentRoot.
 
Old 05-21-2008, 05:21 PM   #3
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Original Poster
Rep: Reputation: 206Reputation: 206Reputation: 206
When I change the ServerName of domain2.tld to www.domain2.tld, it just redirects to www.domain1.tld, like the request isn't being "caught" by Apache. I would change the DNS records, but it works fine for domain1.tld, so I don't see what the difference should be?

And yes, each virtual host has it's own user. :-)

I have mod_rewrite on, which changes domain1.tld to www.domain1.tld, and I have the same code for domain2. However, the problem pervades with and without the rewrite from domain2.tld to www.domain2.tld; either way, I keep getting domain2.tld.

Any other thoughts?

Thanks!
 
  


Reply

Tags
apache, dns, subdomain, virtualhost


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 Virtualhost problem phantom_cyph Linux - Server 6 04-20-2008 12:04 PM
Apache https virtualhost redirection dicou Linux - Server 7 11-29-2007 07:37 AM
VirtualHost Apache 2 Problem Chris_K1 Linux - Networking 0 01-25-2005 10:00 AM
SubDomain Problem - Directories? Quincy Wisdom General 0 07-04-2004 10:46 PM
Subdomain and hosting problem AZIMBD03 Linux - Newbie 4 12-07-2003 04:09 AM


All times are GMT -5. The time now is 04:50 AM.

Main Menu
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