vendredi 1 juin 2018

URI based routing in nginx

I want to direct example.com/1.0 to one laravel application and example.com/1.1 to another laravel application. If example.com is given, it should by default be redirected to example.com/1.1. I am using nginx as the web server. The location blocks in the configuration look as shown below.

location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
try_files $uri =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
limit_req zone=one burst=15 nodelay;

}
location = /50x.html {
root html;
}

The root and index is specified directly in the 443 server block and not inside another location block for /.

How can this be achieved? Any suggestions would be greatly appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire