[英]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 (ie): 我有两个应用程序在同一个服务器上运行,我希望从url(即)中的子路径提供一个:
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 know why this is not working? 你知道为什么这不起作用吗?
I also tried serverpath directive without any success. 我也试过了serverpath指令而没有任何成功。
Do you know how to achieve this? 你知道如何实现这个目标吗?
Thanks in advance. 提前致谢。
Use AliasMatch
instead of Alias
: 使用
AliasMatch
而不是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? 您是否考虑过使用另一个单独的子域名,例如
bar.foo.com
作为其他应用程序?
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.