I managed to solve this problem by the following code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+.php
RewriteRule (.*).php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]
In other words, not to do anything if its a directory.
Yet, my current problem is that css and the images are not loaded until I change the path to the css file and to the images to the absolute path.
Is there any other way to solve it rather then changing all the paths in all the files in the website to absolute.
Thanks a lot.