You were creating an endless redirect. Try this checking for .php
in the request. Also if you're not pulling the slashes the Apache would redirect to a non-existent index.php inside of some folder.
Example 1
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/ $1.php [QSA,L]
This takes the first directory matched and pulls it into the query string.
www.example.com/file/param1/param2/param3
shows this www.example.com/file.php
Example 2
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/(.*)$ $1.php?params=$2 [QSA,L]
This takes the first directory matched and pulls it into the query string. The rest of the URI is added as a parameter
www.example.com/file/param1/param2/param3
shows this www.example.com/file.php?params=param1/param2/param3
Example 3
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?([^/.]+)?/?([^/.]+)?/?([^/.]+)?$ $1.php?p1=$2&p2=$3&p3=$4 [QSA,L]
www.example.com/file/param1/param2/param3
shows this www.example.com/file.php?p1=param1&p2=param2&p3=param3
Note: [QSA]
keeps the existing parameters, so &original_parameter=param
is appended to the rewritten query string.