I
I
iddddy2019-08-24 13:42:57
Nginx
iddddy, 2019-08-24 13:42:57

multiviews in nginx?

how to do so:
www.domain.com/test1 -> www.domain.com/test1.php
www.domain.com/test1/test2-> www.domain.com/test1/test2.php
www.domain.com/ every -> www.domain.com/every.php
this works, but with URLs like www.domain.com/test1/
location ~ ^(.+)/$ {
try_files $uri $1.php?$args;
}
I need no slash at the end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-08-24
@dodo512

location / {
    try_files $uri @m;
}

location @m {
    try_files $uri.php =404;

    include fastcgi_params;
    fastcgi_pass ...;
}

location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass ...;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question