I want get everything up to the "/" and merge with ".php"
works fine, but when the file does not exist I get internal error
RewriteRule ([^\/]*) $1.php
I want get everything up to the "/" and merge with ".php"
works fine, but when the file does not exist I get internal error
RewriteRule ([^\/]*) $1.php
Maybe handling the cases of non-existent file and/or directory might help
RewriteCond %{REQUEST_URI} -d
RewriteCond %{REQUEST_URI} -f
Try handling these cases to avoid errors
You might want to check that what you're rewriting to exists before performing the rewrite, to avoid a loop (noting that your test pattern matches what you rewrite to). One possible approach to this is to do the following:
# Check that the file isn't a directory
RewriteCond %{REQUEST_FILENAME} !-d
# ...nor is it a file
RewriteCond %{REQUEST_FILENAME} !-f
# ...but the result of the rewrite will be
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+) $1.php
This also has the (minor) benefit of showing the original URL in cases where a 404 is generated, provided you're using the stock Apache error message. If you were to rewrite to a non-existent PHP file, the server would say that /something.php could not be found, instead of /something/, but since the rewrite is not performed when the target file does not exist, you get /something/ instead.
If you still get a 500 error, there's likely another conflicting rule in your .htaccess file. You should also check Apache's error log for more detailed information about what the error was, although in this case I suspect that it was an internal redirection limit exceeded message.