Solved

Apache Subdomain DocumentRoot Pathing

Posted on 2010-11-08
14
406 Views
Last Modified: 2012-05-10
Hi,

I've successfully setup a subdomain to my apache server.  My trouble is that this subdomain is not routing to the correct file directory.  It's instead going to the main domain's file directory.  Here's the example:

www.domain.com - resolves to /web
www2.domain.com - should resolve to /web2... BUt it's resolving to /web

Config of www2.domian.com

<VirtualHost *:80>
ServerName www2.domain.com
DocumentRoot /home/www/www.domain.com/web2
  <Location "/*.jsp">
        JkUriSet worker ajp13:localhost:8009
      </Location>

      Alias /usage /var/www/usage
      <Location /usage>
            Allow from all
            Order allow,deny
      </Location>
</VirtualHost>

What have I done wrong??

Thank you tons ~Wendi
0
Comment
Question by:FrostyGirl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 4
14 Comments
 
LVL 20

Expert Comment

by:netcmh
ID: 34085343
Rather than reinvent the wheel, here's a link with a solution

http://muffinresearch.co.uk/archives/2006/08/20/redirecting-subdomains-to-directories-in-apache/
0
 

Author Comment

by:FrostyGirl
ID: 34085400
I don't have a plesk control panel, and I don't have the following referenced config file:  /var/www/vhosts/<domain.com>/conf/vhost.conf
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34085430
have you restarted apache?
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 20

Expert Comment

by:netcmh
ID: 34085441
In it's simplest, I'd write this

Listen 80
NameVirtualHost *

<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>

<VirtualHost *>
ServerName subdomain.domain.com
DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>

at the end of my httpd.conf and restart Apache.
0
 

Author Comment

by:FrostyGirl
ID: 34085442
Yes
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34085450
Do your DNS records for the subdomains must point to the correct IP address?
0
 

Author Comment

by:FrostyGirl
ID: 34085466
Subdomain DNS record points to the main domain's IP.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34085505
How does your DNS entry look like?

Something like this?

domain IN A 123.22.33.45.
subdomain IN A 123.22.33.46.
0
 

Author Comment

by:FrostyGirl
ID: 34085606
C:\WINDOWS\system32>nslookup
Default Server:  d04.m.com
Address:  10.3.1.256

> www2.domain.com
Server:  d04.m.com
Address:  10.3.1.256

Non-authoritative answer:
Name:    www2.domain.com
Address:  72.xxx.18.6


Again, this is pointing to the Main webserver IP.
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34085648
would you be willing to strip off your location and alias commands to test? make sure you restart apache
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34085659
You could also try the ServerAlias directive

<VirtualHost aaa.bbb.ccc.ddd>
ServerName www.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/your/document_root
ServerAlias sub.domain.com
</VirtualHost>
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34085674
Just to confirm, you're using a similar command right?

/etc/init.d/apache2 restart
0
 
LVL 20

Accepted Solution

by:
netcmh earned 500 total points
ID: 34085719
You must provide an absolute path in order for the Redirect directive to work. So I guess, the following should work:

DocumentRoot /home/www/www.domain.com/web2
      Redirect permanent / http://www2.mydomain.com
0
 
LVL 20

Expert Comment

by:netcmh
ID: 34095673
Thanks for the grade
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question