1

I've recently set up a home web/media server and having a few difficulties with a few of the settings. It's working fine for serving webpages etc but I've now reorganised the structure of the main document root and it's now playing hard to get.

Current structure is:

-drive
--sites
---live
----siteA
----siteB
----siteC
---dev
--media
---films
---series

What I'm trying to do is serve siteC when siteA/siteC is called.

For example mydomain.com will present the files that are in siteA, this is fine. SiteB and SiteC do not have their own domains etc and I don't want them to be subfolders of SiteA so what I'd like is for mydomain.com/siteB to serve up the content that is in siteB and the same with siteC.

I'd then like to use the same premise for the media server so myDomain.com/media will display a directory listing of the files within the media directory.

the document root within apache is d:/sites/live, I'm then using virtual hosts to determine what happens. This is fine with the standard mydomanA.com or myDomainB.com but not when trying to achieve what I mentioned above.

This is one of the attempts:

<VirtualHost *:80>
    DocumentRoot "D:/Sites/Live/siteA"
    ServerName www.mydomain.com/siteA
    <Directory "D:/Sites/Live/siteA">
        Order allow,deny
        Allow from all
        AllowOverride All
  </Directory>

Another failed attempt using aliases instead:

<VirtualHost *:80>
    DocumentRoot "D:/Sites/Live/siteA"
    ServerName www.mydomain/siteA
    <Directory "D:/Sites/Live/siteA">
        Order allow,deny
        Allow from all
        AllowOverride All
  </Directory>

  Alias /siteA D:/sites/live/siteA
  <directory "D:/sites/live/siteA">
    Order allow,deny
    AllowOverride All
    </directory>
</VirtualHost>

Thanks for any help, I've been pulling my hair put for the past few hours trying to find a solution.

Edited to answer comment.

The expected input and output would be along the following:

mydomain.com = d:/sites/live/siteA
mydomain.com/siteB = d:/sites/live/siteB
mydomain.com/siteC = d:/sites/live/siteC

and the media server would be:

mydomain.com/media = d:/media
4
  • 1
    I am not sure why you are doing this? Can you explain this so that we can better understand the ultimate goal?
    – closetnoc
    Aug 31, 2014 at 19:46
  • @closetnoc, I want my sites to reside in separate folders and not as a subdirectory of the main site that the domain resolves to. Also, the media is outside of the web root and I still want to be able to access that directory in this manner. does that help it make sense?
    – null
    Aug 31, 2014 at 19:54
  • Do you just have one VirtualHost?
    – MrWhite
    Sep 1, 2014 at 8:14
  • @w3d - No, there are many. I just posted the answer that someone else wonderfully helped with so that it might be able to help others
    – null
    Sep 4, 2014 at 7:36

1 Answer 1

0

User utrecht on serverfault posted this answer:


The following has been tested on Scientific Linux:

<VirtualHost *:80>
  DocumentRoot "/var/www/html/siteA"

  Alias /siteB/ "/var/www/html/siteB/"
  <Directory "/var/www/html/siteB/">
       Order allow,deny
       Allow from all
       AllowOverride All
  </Directory>

  Alias /siteC/ "/var/www/html/siteC/"
  <Directory "/var/www/html/siteC/">
       Order allow,deny
       Allow from all
       AllowOverride All
  </Directory>

  Alias /media/ "/media/"
  <Directory "/media/">
       Options  +Indexes
       Order allow,deny
       Allow from all
       AllowOverride All
   </Directory>
</VirtualHost>

and the test results are as follows:

Input Output
mydomain.com content of siteA
mydomain.com/siteA/404
mydomain.com/siteB/content of siteB
mydomain.com/siteC/content of siteC
mydomain.com/media/content of media

Note: accessing the /media directory resulted in Directory index forbidden by Options directive: logged by the error.log. Adding Options +Indexes solved the issue. This solution was found here.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.