I want something to put in my .htaccess file that will hide the .php file extension for my php files, so going to http://www.example.com/dir/somepage would show them http://www.example.com/dir/somepage.php.
Is there any working solution for this? My site uses HTTPS, if that matters at all.
This is my .htaccess at the moment:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
ErrorDocument 404 /error/404.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
Use this code in your .htaccess under DOCUMENT_ROOT:
It should be noted that this will also effect all HTTP requests, including POST, which will subsequently effect all requests of this kind to fall under this redirection and may potentially cause such requests to stop working.
To resolve this, you can add an exception into the first
RewriteRuleto ignore POST requests so the rule is not allowed to them.