Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How to setup routing via root

$
0
0
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`?

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>