# Enable the rewrite engine
RewriteEngine On

# Rule to redirect from *.php to extensionless URL
# Example: redirects /walkers.php to /walkers
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]

# Rule to internally rewrite an extensionless URL to the corresponding .php file
# Example: when a user visits /walkers, the server silently loads walkers.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA] 