G
G
Grabonovich2020-03-21 22:39:35
Nginx
Grabonovich, 2020-03-21 22:39:35

Why after deleting the file extension php is not processed?

I wanted to remove the .php file extensions from the URL , I spied on the solution - I wrote the following in the /etc/nginx/sites-available/default file :

location / {
    # Удаляем .php
    rewrite     ^(/.*)\.php(\?.*)?$ $1$2 permanent;
    # Удаляем закрывающий слэш
    rewrite     ^/(.*)/$ $1 permanent;
    # Определяем порядок файлов для обработки запроса
    try_files   $uri/index.php $uri.php $uri/ $uri =4$
        }

Now when you go to the URL /feed instead of /feed.php , php is not processed and the browser issues a request to save the file:
5e766d236e687565755065.png
What did I do wrong and how to get nginx to process php with nginx?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2020-03-22
@ky0

You removed the extension - and, apparently, the urls began to be processed by the location, in which there is nothing about the PHP interpreter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question