The problem is that I have only one domain name on which 3 different products need to be run (2 of them PHP based, 1 python). So what I need to do is to treat path in url as different virtual host; ie:
www.domain.com/first_url/
www.domain.com/second_url/
www.domain.com/third_url/
Where first to third will act as separate virtual hosts.
Any clue how to do this?
This example explains how to assign different PHP version per directory, it can also be adapted to add Python support by running Python interpreter as
fast_cgi
on particular portFor the purpose of the example I assume there is separate directory for each PHP version and they are named according to PHP version that runs them, but this can be adjusted
create symbolic links to directories that should be handled by different PHP versions
then add following lines to /etc/apache2/sites-enabled/000-default.conf in default virtual host
*:80
(for your need you can setup one more fast cgi handler here for the website that requires Python), I assume php
5.6.5
runs on port9999
,7.0.2
runs on port9998
etc...assuming your server is pointed by
example.com
you can test it onA "virtual host" in apache works on domain names only, not on parts of the path. You cannot achieve what you want.
It's been a while since this question was asked but since I was looking for a solution for a similar kind of problem, I'll add the solution.
This can be achieved by using Alias or AliasMatch directive. More details can be found here:
http://httpd.apache.org/docs/2.2/mod/mod_alias.html
You probably want to do something with the apache-config directives, since you're asking for a virtualhost solution. Apache can only work with virtualHosts as actual domains, as @cweiske explained.
The solution in this case would be to either use a
.htaccess
file in the sub-directories you're working in, or to set up a<Directory "/web/root/subdir">..</Directory>
block within your current (virtual-)host config.You could also choose to host them on different sub-domains if you per-se want to run them as VirtualHosts ('app1.domain.org')