Apache alias virtual host

18,865

Use AliasMatch instead of Alias:

AliasMatch ^/bar/?(.*) /var/www/bar/$1

Or, in your case:

AliasMatch ^/blog/?(.*) /webapps/blog/current/$1
Share:
18,865
Rafael
Author by

Rafael

Updated on June 17, 2022

Comments

  • Rafael
    Rafael about 2 years

    I have two applications running in the same server and I would like to have one served from subpath in the url (i.e):

    • foo.com -> /var/www/foo
    • foo.com/bar -> /var/www/bar

    I'm trying to do an alias but is not working:

    <VirtualHost *:80>
      ServerAdmin [email protected]
      ServerName foo.com
      DocumentRoot /webapps/foo/current/public
      <Directory /webapps/foo/current/public>
        AllowOverride all
        Options -MultiViews
      </Directory>
      RailsEnv staging
      Alias /blog /webapps/blog/current
     <Directory /webapps/blog/current>
       allow from all
       Options +Indexes
     </Directory>
    

    Do you know why this is not working?

    I also tried serverpath directive without any success.

    Do you know how to achieve this?

    Thanks in advance.