I have one domain like http://example.com
. This results in a page loaded from /var/www/example
. Now I want all requests to http://example.com/site2
to be resolved to the folder /var/www/site2
.
This is the basic idea and I tried to accomplish it like this (which did not work):
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/example
DirectoryIndex /index.html index.html
#<LocationMatch "^/site2.*">
# RewriteEngine on
# RewriteRule . /example2/index.html [L]
#</LocationMatch>
AliasMatch "/site2(.*)" "/var/www/site2$1"
<Directory /var/www/site2>
Require all granted
AllowOverride all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
I tried using the Alias
directive and LocationMatch
to rewrite stuff to the correct URL when arriving at the /site2
URL. This was my conf. At http://example.com/site2/
it would result in the index.html
from http://example.com/
. Only when requesting http://example.com/site2/index.html
.
<VirtualHost *:80>
DocumentRoot /var/www/example
DirectoryIndex /index.html index.html
Alias "/site2" "/var/www/site2"
<Directory /var/www/site2>
Require all granted
AllowOverride all
</Directory>
</VirtualHost>
I would also like to have all PHP requests passed to their own FPM pool. The requests for http://example.com
should be passed to fcgi://127.0.0.1:9000
and the request for http://example.com/site2
should go to fcgi://127.0.0.1:9001
.
How can I achieve this?
localhost
? Thelocalhost
(loopback interface) is accessible only from the local machine./index.html
fromDirectoryIndex
. Usually you don't need path and maybe this is the reason why Apache shows only the index from the the main directory.