V
V
Vladimir Merk2015-01-09 14:28:11
Nginx
Vladimir Merk, 2015-01-09 14:28:11

Is it possible to set up multiple subdomains per directory but different index files?

Hello.
Is it possible to configure apache2+nginx so that different subdomains point to the same directory but have different index files?
For example:
sub1.site.loc >> /var/www/site.loc/sub/index1.php
sub2.site.loc >> /var/www/site.loc/sub/index2.php
sub3.site.loc > > /var/www/site.loc/sub/index3.php
sub4.site.loc >> /var/www/site.loc/sub/index4.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Zhavoronkov, 2015-01-09
@Ascendant

Can. If your PHP handles nginx you can use map. Here is an excerpt from the config:

map $http_host $index_file {
        nginx-test.loc          index.php;
        one.nginx-test.loc      index1.php;
        two.nginx-test.loc      index2.php;
}

server {
        listen 80;
        server_name nginx-test.loc *.nginx-test.loc;

        root /var/www/nginx-test;

        index $index_file;

        # остальные параметры
}

Or you can write your own config for each subdomain, in general there are a lot of options.
For Apache2, you can write a similar config.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question