Answer the question
In order to leave comments, you need to log in
Nginx: How to serve another file?
Greetings, if there is a specific host in the $http_referer variable, it is necessary to give another html file, namely to give and not a redirect to another file.
Now this is not working:
server {
listen 80 default_server;
listen 443 default_server;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html;
error_log /dev/null crit;
access_log off;
location / {
if ($http_referer ~ 'http://google.ru/apps/') {
rewrite ^ apps/index.html last;
}
try_files $uri $uri/ /index.html;
}
}
Answer the question
In order to leave comments, you need to log in
nginx.org/ru/docs/http/ngx_http_core_module.html#t...
https://nginx.org/ru/docs/http/ngx_http_map_module...
map $http_referer $index {
default $uri;
'~http://google.ru/apps/' '/apps/index.html';
}
try_files $index $uri $uri/ /index.html;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question