Let's say I had this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^page(?:/error(?:/([^/]+))?)?/?$ page.php?error=$1 [L,QSA]
page/
and onwards (page/error/
etc) gives me a 500 error.
You can use this rule to make last slash and other URI components optional:
Full .htaccess: