Answer the question
In order to leave comments, you need to log in
Is it possible to / give index.html for a request, and for other requests - to transfer processing further?
Is it possible to send the index.html file to nginx when requesting example.com, and when requesting example.com/anything-else, pass the request to php for processing?
PS Removed irrelevant directives from the config, like listen.
server {
root /var/www/php/public; # Здесь находится index.php
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location = / { # Здесь хочу отдать index.html
root /var/www/static; # здесь физически находится index.html
try_files $uri $uri/ /index.html?$query_string;
}
location / { # Здесь хочу обрабатывать остальные запросы, как обычно
try_files $uri $uri/ /index.php?$query_string;
}
}
Answer the question
In order to leave comments, you need to log in
In the first case, you do not need to do try_files $uri.
You need to try_files / index.html
That is, the config should look like this:
server {
root /var/www/php/public; # Здесь находится index.php
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location = / { # Здесь хочу отдать index.html
root /var/www/static; # здесь физически находится index.html
try_files /index.html =404;
}
location / { # Здесь хочу обрабатывать остальные запросы, как обычно
try_files $uri $uri/ /index.php?$query_string;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question