Alias the DocumentRoot

apache-2.2

I have a web app (oldapp.com) that stores images in a sub-folder (oldapp.com/images) of the DocumentRoot (aka web root). I am rebuilding the app on a different domain (newapp.com) and have created a sub-domain specifically for storing images (images.newapp.com). While I am building, testing, and using the new app, I still need the old app to continue accessing that old image sub-folder. All of this is being done on the same server. I need the new sub-domain to have the same access to the images that are in the old sub-folder.

For this particular case, I do not have the option of changing the DocumentRoot directive. I do have access to Alias and Redirect.

Can I Alias the DocumentRoot of the images.newapp.com vhost to the old sub-directory of another vhost (/var/www/vhost/oldapp.com/httpdocs/images)?

In other words, something like this in the images.newapp.com vhost block:

AliasMatch ^/(.*) /var/www/vhost/oldapp.com/httpdocs/images$1

Best Answer

You should be able to do that, but you need to add the trailing slash to the images directory before the $1. You also need to make sure that you've got the correct access rights to the images directory, both in the filesystem and in the apache config.

Related Topic