M
M
Mazino2019-11-29 15:49:02
Nginx
Mazino, 2019-11-29 15:49:02

How to write path processing rules in nginx when there is a file in the path?

There is an nginx server that must process the domain in two different ways for different paths. For example ,
if the path is /url , then give the file from 1 directory, if the path is /url/to give the file from another path. The problem is that in both cases the php. As a result, it turns out that some paths look like this:
/url/to/api.php/api/path and nginx considers api.php a directory and issues an appropriate error when it sees that there is no such directory.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-11-29
@ky0

There can be only one file in the url - at the end of the path itself and before the arguments after the question mark. In your case api.php, it's part of the path.
If you need to handle such urls somehow in a special way, you can use a regular expression followed by rewrite, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question