T
T
teub742017-07-02 12:40:29
PHP
teub74, 2017-07-02 12:40:29

Should all requests from any php file be transferred to index.php?

How to make it so that all requests from any php file are transferred to index.php, without checking for the existence of a file (try_files), through Nginx?
Now the server has a routing setup, that is, if the file does not exist, then it returns index.php. However, if you call example.com/func.php
through the address bar , this file will open.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
teub74, 2017-07-02
@teub74

Found the answer:

location ~ \.php$ {
...
fastcgi_param    SCRIPT_FILENAME   $document_root/index.php;
...
}

B
Boris Korobkov, 2017-07-02
@BorisKorobkov

try_files is needed to serve static (css, js, jpg/png, etc.)
func.php and other includes should not be accessible from the web! Move them up a level.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question