I have implemented the following Nginx code:
location / {
try_files $uri $uri.php $uri/ @extensionless-php;
index index.html index.htm index.php;
}
location ~ \.php$ {
try_files $uri =404;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
It's successful in removing the .php
extension, but the page also loads with the .php
extension. For example, both http://example.com/pages/page.php
and http://example.com/pages/page
work.
Kindly help me so that the page only loads without the .php
extension.