Mobile app version of vmapp.org
Login or Join
Marchetta884

: Apache Redirect to another folder, both within and outside document root 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

@Marchetta884

Posted in: #Apache2 #Htaccess #Server #Virtualhost #WebHosting

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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Marchetta884

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jessie594

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme