I have two applications running in the same server and I would like to have one served from subpath in the url (i.e):
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.
The Apache HTTP server supports virtual hosts, meaning that it can respond to requests that are directed to multiple IP addresses or host names that correspond to the same host machine. You can configure each virtual host to provide different content and to behave differently.
To use name-based virtual hosting, you must designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the NameVirtualHost directive.
There are two types of virtual hosts on Apache: IP-Based Virtual Hosting – every individual website on the Apache Server uses a different, unique IP address. Name-Based Virtual Hosts – enables you to add multiple domains using a single IP address.
Use AliasMatch
instead of Alias
:
AliasMatch ^/bar/?(.*) /var/www/bar/$1
Or, in your case:
AliasMatch ^/blog/?(.*) /webapps/blog/current/$1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With