1RewriteEngine On
2RewriteCond %{REQUEST_FILENAME} !-f
3RewriteRule ^([^/]+)/$ $1.php
4RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
5RewriteCond %{REQUEST_FILENAME} !-f
6RewriteCond %{REQUEST_FILENAME} !-d
7RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
8RewriteRule (.*)$ /$1/ [R=301,L]
9