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

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.

  • I was going by the example at httpd.apache.org/docs/2.2/mod/mod_alias.html which does not have a trailing slash. Apparently that slash was what I needed. Thanks. – SunSparc Jul 13 '12 at 19:48
  • The difference is that in the example there was also no slash before the capture. By putting it first, you removed it from the reference you captured - if you'd had the slash inside the capture it would also have worked. – Jenny D Jul 14 '12 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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