Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Apache Subdomain DocumentRoot Pathing

Posted on 2010-11-08
14
Medium Priority
?
412 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 21

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 21

Expert Comment

by:netcmh
ID: 34085430
have you restarted apache?
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 21

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 21

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 21

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 21

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 21

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 21

Expert Comment

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

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

Accepted Solution

by:
netcmh earned 2000 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 21

Expert Comment

by:netcmh
ID: 34095673
Thanks for the grade
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

636 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