Welcome! Log In Create A New Profile

Advanced

How to setup routing via root

Posted by BugBuster 
How to setup routing via root
April 16, 2020 04:55AM
Sorry for dumb question but is it possible to get a part of URL right after domain name via `server_name` variable?


server {
listen 80;
index index.php index.html;
server_name ~^localhost/(?<project>)/.+$;
root /var/www/$project/public;
...
}

The idea is to change root path in relation of it's folder structure:

1) "/var/www/project-one/public/index.php"
2) "/var/www/project-two/public/index.php"

So I would be able to reach entry point of each project by requests:

"http://localhost/project-one/" ->> "/var/www/project-one/public/"

"http://localhost/project-two/" ->> "/var/www/project-two/public/"

How to implement such behavior w/o using `alias`?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 89
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready