开发者

Apache alias virtual host

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 webmaster@foo.com
  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 开发者_JS百科know why this is not working?

I also tried serverpath directive without any success.

Do you know how to achieve this?

Thanks in advance.


Use AliasMatch instead of Alias:

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

Or, in your case:

AliasMatch ^/blog/?(.*) /webapps/blog/current/$1


Have you considered using another separate subdomain, like bar.foo.com for your other application?

Here's how you'd set that up:

<VirtualHost *:80>
    ServerAdmin webmaster@foo.com
    DocumentRoot /var/www/foo
    ServerName foo.com
    ServerAlias foo.com www.foo.com
    ErrorLog logs/foo.com_Error_Log
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@foo.com
    DocumentRoot /var/www/bar
    ServerName bar.foo.com
    ErrorLog logs/bar.foo.com_Error_Log
</VirtualHost>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜