RewriteEngine On

# NIE RUSZAJ realnych plików i katalogów
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# USUŃ index.(php|html|htm|shtml) z URL
RewriteCond %{THE_REQUEST} \s/+(.*/)?index\.(php|html|htm|shtml)\s [NC]
RewriteRule ^ %1 [R=301,L]

# /nazwa -> /nazwa.(php|html|htm|shtml)
RewriteCond %{REQUEST_FILENAME}\.(php|html|htm|shtml) -f
RewriteRule ^(.+)$ $1.%1 [L]

# /folder -> /folder/index.(php|html|htm|shtml)
RewriteCond %{REQUEST_FILENAME}/index\.(php|html|htm|shtml) -f
RewriteRule ^(.+)$ $1/index.%1 [L]