Answer the question
In order to leave comments, you need to log in
How to force nginx to give a separate folder for domain.com/sub?
We have a project in Laravel.
And it took a part of requests for / sub to be processed by a separate script. But bad luck, a separate script is also written in Laravel and is essentially an independent project.
I just can't get my brain to figure out how to change the nginx config to make everything work. Help to understand, please.
Now the config is standard like everyone else:
server {
# все как у всех
listen 80 default_server;
server_name domain.cm;
root /home/domain.com/public;
index index.php;
# тут все стандартно
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# и тут все стандартно
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location /sub {
alias /home/domain.com/sub/public/;
try_files $uri $uri/ /index.php?$query_string;
}
location /sub {
root /home/domain.com/sub/public/;
rewrite ^(.*) /index.php$1;
}
Answer the question
In order to leave comments, you need to log in
It's funny. The same question came up again. It’s useful to ask a question, but it turns out that everything is already there. For over a year now. And the situation is one on one. Only in a different place with different people and a different project.
I don’t know if the question will rise from the comment to the top in the search results. But it's as relevant as ever.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question