I have a question about my .htaccess-code. It is doing the following:
- Adding a trailing slash to every URL
- Removing the .php file extension.
This works, so if I type domain.com/page/, the browser shows the content of domain.com/page.php. If I type domain.com/page (without the trailing slash), the browser redirects to domain.com/page/.
BUT if I type domain.com/page.php the browser does not redirect to domain.com/page/.
Is there a way to redirect the request domain.com/page.php to domain.com/page/?
Here's my current .htaccess-code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !(^$|\.[a-zA-Z0-9]{1,5}|/)$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^((/?[^/]+){1,2})/$ $1.php [L]
Thank you for your help!