Reputation: 379
After some googling, I was able to allow my php website load without having to put the ".php", but I want to return an object not found error if it finds the ".php", hence making it a requirement to remove the ".php" extension.
Upvotes: 0
Views: 47
Reputation: 151
You could try something like this:
// PHP 8
if(str_contains($_SERVER["REQUEST_URI"], ".php")) {
http_response_code(404);
echo "404 - page not found";
}
// PHP < 8
if(strpos($_SERVER["REQUEST_URI"], ".php") !== false) {
http_response_code(404);
echo "404 - page not found";
}
Upvotes: 1