-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
2
  • Could you be more specific regarding the input and expected output? E.g: IP/siteA = D:/Sites/Live/siteA, IP/siteB = D:/Sites/Live/siteB and IP/siteC = D:/Sites/Live/siteC. Are these the expectations?
    – 030
    Aug 31, 2014 at 19:08
  • @utrecht, Hi, yes, you're absolutely right with the assumptions, I've edited the question slightly to show the examples.
    – null
    Aug 31, 2014 at 19:12

1 Answer 1

3

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.

5
  • I don't suppose you could help me a little further? I've replicated with the media folder but receive a 403 error - folders have correct permissions. There's no html etc in the folder as I was just expecting a dir listing. And...Is there also a way for the urls to ignore case? If I use my domain.com/siteA it will work but mydomain.com/sitea results in an error. Thanks again for your help
    – null
    Aug 31, 2014 at 20:27
  • 1
    I will update the answer ASAP.
    – 030
    Aug 31, 2014 at 20:37
  • 1
    @SteveGreen The configuration regarding the media directory has been added. Regarding the case insensitive URLs, this Q&A could help or using an .htaccess file. An other option is to use multiple Aliases, e.g. /siteb/ and /siteB/.
    – 030
    Aug 31, 2014 at 22:17
  • thanks utrect, i played with multiple aliases but thought there must be a cleaner way so I'll look at the htaccess option. :) Thank you also for the help with the media, i found a similar question that was answered that didn't work for me but now about to try your suggestion, thanks again.
    – null
    Sep 1, 2014 at 5:44
  • thanks again!!! I found a solution in the comments of a related post :) For me the following worked which is copied from example in /etc/apache2/apache2.conf: ` <Directory /srv/www/default> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> `
    – null
    Sep 1, 2014 at 6:29

Not the answer you're looking for? Browse other questions tagged .