O
O
Onotolius2020-09-06 09:38:41
Nginx
Onotolius, 2020-09-06 09:38:41

Why can't I configure the location directive?

Hello dear experts.
I have nginx 1.14, the task is this: set up the location directive in the server block so that any request like site.com/ha_ha_ha, site.com/100500 or site.com/erfkgkiycblry/bugaga does not matter, it requests index.php

Here are the options that I tried and which do not work, when requesting the server, Content-Type: application/octet-stream is returned and the browser forces something to download.. :

location ~ / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /.+ {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /(.+) {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ ^/([^/]/)?.+ {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ ^/([^/]/)?(.+) {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /([^/]/)?.+ {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /([^/]/)?(.+) {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /[a-z]+ {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /([a-z]+) {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ /\D+ {
try_files $uri $uri/ /index.php?$query_string;
}


The only thing that worked is this (requests with numbers will open, for example site.com/100500):

location ~ /\d+ {
try_files $uri $uri/ /index.php?$query_string;
}


In general, it doesn't work at all. As I understand it, if at least one Latin letter is missing in the location directive and everything consists only of a regular expression, then nothing will work, the exception is ~ / \ d +

Help me figure it out.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-09-06
@Login8

location / {
try_files $uri $uri/ /index.php?$query_string;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question