G
G
GoldFox20152020-07-03 21:00:11
PHP
GoldFox2015, 2020-07-03 21:00:11

php nginx redirect?

Hello everyone, there was not a big problem.
There is a test.php file on the server, and it opens only at my-site.ru/test.php.
How to make it open on my-site.ru/test?
Web server: nginx.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-07-03
@GoldFox2015

rewrite ^/test$ /test.php;
Or a variant with try_files.

location / {
    try_files $uri  @php;
}

location @php {
    try_files $uri.php =404;
    
    fastcgi_pass ... ;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question