Apache2 "pseudo" doc root

Posted by Brent on Pro Webmasters See other posts from Pro Webmasters or by Brent
Published on 2012-02-13T08:06:08Z Indexed on 2012/04/13 17:43 UTC
Read the original article Hit count: 459

Filed under:

I have several folders in my /www folder that contain various applications. To keep things organized, I keep them in their own folders -- this includes my base application.

Examples:

  1. phpmyadmin = /www/phpmyadmin
  2. phpvirtualbox = /www/phpvirtualbox
  3. root domain site = /www/Landing

The reason I segregate all of my sites is that I actively develop on some of these (my root site) and when I publish via Visual Studio, I choose to delete prior to upload - if I put the Landing page in the base folder, it would be devastating for me.

My goal is that when I go to www.example.com - I go to my page. If I go to www.example.com/phpmyadmin, it does not work because of this in the Apache2 folder:

<Location "/"> # Error is the "/"
  Allow from all
  Order allow,deny
  MonoSetServerAlias domain
  SetHandler mono
  SetOutputFilter DEFLATE
  SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>

If I change the location to say "/Other", then the base site is broken, and the aliases are restored for the other sites. If it is "/", then the base site works and no aliases work.

What could I do to allow it to treat my /www/Landing as my webroot, but when I go to an alias, it GOES to the alias.

Edit: Added in the default VirtualHost info.

DocumentRoot /var/www
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName www.example.com

ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType text/css "access plus 1 days"

  MonoServerPath domain "/usr/bin/mod-mono-server4"
  MonoDebug domain true
  MonoSetEnv domain MONO_IOMAP=all
  MonoApplications domain "/:/var/www/Landing"

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.*) /Landing/$1 [L]


#Need to watch what the Location is set to. Can cause issues for alias
<Location "/">
  Allow from all
  Order allow,deny
  MonoSetServerAlias domain
  SetHandler mono
  SetOutputFilter DEFLATE
  SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

© Pro Webmasters or respective owner

Related posts about apache2